Work on login form stuff

This commit is contained in:
Melody Becker 2024-10-28 08:36:11 +01:00
parent 53e6418e89
commit 952949b609
11 changed files with 127 additions and 22 deletions

View file

@ -23,6 +23,7 @@ export interface PasskeySignature {
export default class Auth extends Component<PasskeySignature> { export default class Auth extends Component<PasskeySignature> {
@tracked username: string = ''; @tracked username: string = '';
@tracked error: string | undefined; @tracked error: string | undefined;
@tracked isLogin = true;
@service declare auth: AuthService; @service declare auth: AuthService;
@action async startLogin() { @action async startLogin() {

View file

@ -0,0 +1,12 @@
<div class="login-wrapper">
<label>
<Input
@type="text"
@value={{this.username}}
@placeholder="Username"
/>
</label>
<div type="button" class="login-start-button" {{on "click" this.onLoginStart}}>
Login
</div>
</div>

View file

@ -0,0 +1,24 @@
import { action } from '@ember/object'
import Component from '@glimmer/component'
import { tracked } from '@glimmer/tracking'
export interface AuthLoginSignature {
// The arguments accepted by the component
Args: {}
// Any blocks yielded by the component
Blocks: {
default: []
}
// The element to which `...attributes` is applied in the component template
Element: null
}
export default class AuthLogin extends Component<AuthLoginSignature> {
@tracked username = ''
@action onLoginStart() {
console.log('Starting login for username ' + this.username)
// Check if username is approved for login
// If it is, continue with login
}
}

View file

@ -1,6 +1,6 @@
<div class="registration-form"> <div class="registration-form">
<h1 class="registration-form-username">username: {{this.args.username}}</h1> <h1 class="registration-form-username">username: {{this.args.username}}</h1>
<div class="registration-form-displayname"> <div class="registration-form-displayname-wrapper">
<label> <label>
Displayname Displayname
<Input <Input
@ -10,7 +10,7 @@
/> />
</label> </label>
</div> </div>
<div class="registration-form-description"> <div class="registration-form-description-wrapper">
<label> <label>
Description Description
<Input <Input
@ -20,13 +20,13 @@
/> />
</label> </label>
</div> </div>
<div class="registration-form-mail"> {{!--<div class="registration-form-mail-wrapper">--}}
<label> {{!-- <label>--}}
Email {{!-- Email--}}
<Input @type="text" @value={{this.email}} placeholder="Email address" /> {{!-- <Input @type="text" @value={{this.email}} placeholder="Email address" />--}}
</label> {{!-- </label>--}}
</div> {{!--</div>--}}
<div class="registration-form-gender"> <div class="registration-form-gender-wrapper">
<Util::StringArray <Util::StringArray
@list={{this.gender}} @list={{this.gender}}
@onNewElement={{this.genderAddedHandler}} @onNewElement={{this.genderAddedHandler}}
@ -34,10 +34,10 @@
/> />
</div> </div>
<p>{{this.extracted}}</p> <p>{{this.extracted}}</p>
<div class="register-form-being"> <div class="register-form-being-wrapper">
<Util::Multiselect @elements={{this.beingTypes}} /> <Util::Multiselect @elements={{this.beingTypes}} />
</div> </div>
<div class="register-form-default-post-mode"> <div class="register-form-default-post-mode-wrapper">
<Util::OneOfArray <Util::OneOfArray
@elements={{array "Public" "Local" "Followers" "Direct"}} @elements={{array "Public" "Local" "Followers" "Direct"}}
@selected={{this.defaultpostmode}} @selected={{this.defaultpostmode}}
@ -45,7 +45,7 @@
@required={{true}} @required={{true}}
/> />
</div> </div>
<div class="register-form-follow-approval"> <div class="register-form-follow-approval-wrapper">
<label> <label>
Require approval for follow requests Require approval for follow requests
<Input <Input
@ -55,15 +55,14 @@
/> />
</label> </label>
</div> </div>
<div class="register-form-indexable"> <div class="register-form-indexable-wrapper">
<label> <label>
Whether the account is indexable Whether the account is indexable
<Input @type="checkbox" name="Indexable" @checked={{this.indexable}} /> <Input @type="checkbox" name="Indexable" @checked={{this.indexable}} />
</label> </label>
</div> </div>
<div class="register-form-custom-fields"> <div class="register-form-custom-fields-wrapper">
<Util::MapEdit @list={{this.customProperties}} /> <Util::MapEdit @list={{this.customProperties}} />
</div> </div>
{{! TODO: Custom fields (Two string arrays, lets go. Definitely won't be a pain to sync them up) }}
{{! TODO: Icon, Background, Banner }} {{! TODO: Icon, Background, Banner }}
</div> </div>

View file

@ -1,7 +1,7 @@
import Component from '@glimmer/component'; import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking'; import { tracked } from '@glimmer/tracking';
export interface AuthRegistrationFormSignature { export interface AuthPostRegistrationFormSignature {
// The arguments accepted by the component // The arguments accepted by the component
Args: { Args: {
username: string; username: string;
@ -14,7 +14,7 @@ export interface AuthRegistrationFormSignature {
Element: null; Element: null;
} }
export default class AuthRegistrationForm extends Component<AuthRegistrationFormSignature> { export default class AuthPostRegistrationForm extends Component<AuthPostRegistrationFormSignature> {
@tracked displayname: string = this.args.username; @tracked displayname: string = this.args.username;
@tracked description: string = ''; @tracked description: string = '';
@tracked gender: Array<{ value: string }> = []; @tracked gender: Array<{ value: string }> = [];

View file

@ -0,0 +1 @@
{{yield}}

View file

@ -0,0 +1,14 @@
import Component from '@glimmer/component';
export interface AuthRegisterStartSignature {
// The arguments accepted by the component
Args: {};
// Any blocks yielded by the component
Blocks: {
default: [];
};
// The element to which `...attributes` is applied in the component template
Element: null;
}
export default class AuthRegisterStart extends Component<AuthRegisterStartSignature> {}

View file

@ -1,2 +1,4 @@
{{page-title "RegisterForm"}} {{page-title "RegisterForm"}}
<Auth::RegistrationForm @username="bob" /> <Auth::Login />
<br>
<!--<Auth::PostRegistrationForm @username="bob" />-->

View file

@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'frontend-reactive/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | auth/login', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<Auth::Login />`);
assert.dom().hasText('');
// Template block usage:
await render(hbs`
<Auth::Login>
template block text
</Auth::Login>
`);
assert.dom().hasText('template block text');
});
});

View file

@ -10,15 +10,15 @@ module('Integration | Component | auth/registration-form', function (hooks) {
// Set any properties with this.set('myProperty', 'value'); // Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... }); // Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<Auth::RegistrationForm />`); await render(hbs`<Auth::PostRegistrationForm />`);
assert.dom().hasText(''); assert.dom().hasText('');
// Template block usage: // Template block usage:
await render(hbs` await render(hbs`
<Auth::RegistrationForm> <Auth::PostRegistrationForm>
template block text template block text
</Auth::RegistrationForm> </Auth::PostRegistrationForm>
`); `);
assert.dom().hasText('template block text'); assert.dom().hasText('template block text');

View file

@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'frontend-reactive/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | auth/register-start', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<Auth::RegisterStart />`);
assert.dom().hasText('');
// Template block usage:
await render(hbs`
<Auth::RegisterStart>
template block text
</Auth::RegisterStart>
`);
assert.dom().hasText('template block text');
});
});