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

View file

@ -1,7 +1,7 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
export interface AuthRegistrationFormSignature {
export interface AuthPostRegistrationFormSignature {
// The arguments accepted by the component
Args: {
username: string;
@ -14,7 +14,7 @@ export interface AuthRegistrationFormSignature {
Element: null;
}
export default class AuthRegistrationForm extends Component<AuthRegistrationFormSignature> {
export default class AuthPostRegistrationForm extends Component<AuthPostRegistrationFormSignature> {
@tracked displayname: string = this.args.username;
@tracked description: 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"}}
<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');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<Auth::RegistrationForm />`);
await render(hbs`<Auth::PostRegistrationForm />`);
assert.dom().hasText('');
// Template block usage:
await render(hbs`
<Auth::RegistrationForm>
<Auth::PostRegistrationForm>
template block text
</Auth::RegistrationForm>
</Auth::PostRegistrationForm>
`);
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');
});
});