More work on post registration form
This commit is contained in:
parent
952949b609
commit
8b03454d6f
27 changed files with 247 additions and 51 deletions
|
@ -0,0 +1,18 @@
|
|||
<div class="auth-wrapper">
|
||||
<div class="auth-username-wrapper">
|
||||
<label>
|
||||
Username
|
||||
<Input
|
||||
@type="text"
|
||||
@value={{this.username}}
|
||||
placeholder="Username"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div type="button" class="auth-button-login" {{on "click" this.startLogin}}>
|
||||
Login
|
||||
</div>
|
||||
<div type="button" class="auth-button-register" {{on "click" this.startRegistration}}>
|
||||
Register
|
||||
</div>
|
||||
</div>
|
|
@ -9,7 +9,7 @@ import {
|
|||
} from '@simplewebauthn/browser';
|
||||
import type AuthService from 'frontend-reactive/services/auth';
|
||||
|
||||
export interface PasskeySignature {
|
||||
export interface AuthSignature {
|
||||
// The arguments accepted by the component
|
||||
Args: {};
|
||||
// Any blocks yielded by the component
|
||||
|
@ -20,14 +20,15 @@ export interface PasskeySignature {
|
|||
Element: null;
|
||||
}
|
||||
|
||||
export default class Auth extends Component<PasskeySignature> {
|
||||
export default class Auth extends Component<AuthSignature> {
|
||||
@tracked username: string = '';
|
||||
@tracked error: string | undefined;
|
||||
@tracked isLogin = true;
|
||||
//@tracked isLogin = true;
|
||||
@service declare auth: AuthService;
|
||||
|
||||
@action async startLogin() {
|
||||
try {
|
||||
// TODO: Check if account exists and is alowed to login
|
||||
this.auth.startLogin(this.username);
|
||||
} catch (error: any) {
|
||||
this.error = 'Error: ' + error.message;
|
||||
|
@ -36,7 +37,12 @@ export default class Auth extends Component<PasskeySignature> {
|
|||
|
||||
@action async startRegistration() {
|
||||
try {
|
||||
this.auth.startRegistration(this.username);
|
||||
// TODO: Check if handle is already taken
|
||||
await this.auth.startRegistration(this.username);
|
||||
// After registration, log in immediately to obtain a valid session token
|
||||
// for the "post" registration data, such as email
|
||||
await this.auth.startLogin(this.username);
|
||||
// And after login,
|
||||
} catch (error: any) {
|
||||
this.error = 'Error: ' + error.message;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<Input
|
||||
@type="text"
|
||||
@value={{this.username}}
|
||||
@placeholder="Username"
|
||||
placeholder="Username"
|
||||
/>
|
||||
</label>
|
||||
<div type="button" class="login-start-button" {{on "click" this.onLoginStart}}>
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
import { action } from '@ember/object'
|
||||
import Component from '@glimmer/component'
|
||||
import { tracked } from '@glimmer/tracking'
|
||||
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: {}
|
||||
Args: {};
|
||||
// Any blocks yielded by the component
|
||||
Blocks: {
|
||||
default: []
|
||||
}
|
||||
default: [];
|
||||
};
|
||||
// The element to which `...attributes` is applied in the component template
|
||||
Element: null
|
||||
Element: null;
|
||||
}
|
||||
|
||||
export default class AuthLogin extends Component<AuthLoginSignature> {
|
||||
@tracked username = ''
|
||||
@tracked username = '';
|
||||
|
||||
@action onLoginStart() {
|
||||
console.log('Starting login for username ' + this.username)
|
||||
console.log('Starting login for username ' + this.username);
|
||||
// Check if username is approved for login
|
||||
// If it is, continue with login
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
/>
|
||||
</label>
|
||||
</div>
|
||||
<Util::MailEntry @data={{this.mail}}/>
|
||||
<div class="registration-form-description-wrapper">
|
||||
<label>
|
||||
Description
|
||||
|
@ -20,24 +21,20 @@
|
|||
/>
|
||||
</label>
|
||||
</div>
|
||||
{{!--<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">
|
||||
<p class="registration-form-gender-info">Add your preferred pronouns</p>
|
||||
<Util::StringArray
|
||||
@list={{this.gender}}
|
||||
@onNewElement={{this.genderAddedHandler}}
|
||||
@onDeleteElement={{this.genderRemovedHandler}}
|
||||
/>
|
||||
</div>
|
||||
<p>{{this.extracted}}</p>
|
||||
<div class="register-form-being-wrapper">
|
||||
<p class="registration-form-being-info">Select the type of being you are. Multiselect is possible</p>
|
||||
<Util::Multiselect @elements={{this.beingTypes}} />
|
||||
</div>
|
||||
<div class="register-form-default-post-mode-wrapper">
|
||||
<p class="registration-form-default-post-mode-info">Select the default mode for your posts</p>
|
||||
<Util::OneOfArray
|
||||
@elements={{array "Public" "Local" "Followers" "Direct"}}
|
||||
@selected={{this.defaultpostmode}}
|
||||
|
@ -65,4 +62,4 @@
|
|||
<Util::MapEdit @list={{this.customProperties}} />
|
||||
</div>
|
||||
{{! TODO: Icon, Background, Banner }}
|
||||
</div>
|
||||
</div>
|
|
@ -1,27 +1,29 @@
|
|||
import Component from '@glimmer/component';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { action } from '@ember/object'
|
||||
import Component from '@glimmer/component'
|
||||
import { tracked } from '@glimmer/tracking'
|
||||
import isValidMail from 'frontend-reactive/helpers/is-valid-mail'
|
||||
|
||||
export interface AuthPostRegistrationFormSignature {
|
||||
// The arguments accepted by the component
|
||||
Args: {
|
||||
username: string;
|
||||
};
|
||||
username: string
|
||||
}
|
||||
// Any blocks yielded by the component
|
||||
Blocks: {
|
||||
default: [];
|
||||
};
|
||||
default: []
|
||||
}
|
||||
// The element to which `...attributes` is applied in the component template
|
||||
Element: null;
|
||||
Element: null
|
||||
}
|
||||
|
||||
export default class AuthPostRegistrationForm extends Component<AuthPostRegistrationFormSignature> {
|
||||
@tracked displayname: string = this.args.username;
|
||||
@tracked description: string = '';
|
||||
@tracked gender: Array<{ value: string }> = [];
|
||||
@tracked displayname: string = this.args.username
|
||||
@tracked description: string = ''
|
||||
@tracked gender: Array<{ value: string }> = []
|
||||
@tracked beingTypes: Array<{
|
||||
name: string;
|
||||
checked: boolean;
|
||||
description: string;
|
||||
name: string
|
||||
checked: boolean
|
||||
description: string
|
||||
}> = [
|
||||
{
|
||||
name: 'Human',
|
||||
|
@ -53,17 +55,22 @@ export default class AuthPostRegistrationForm extends Component<AuthPostRegistra
|
|||
description: 'Doll',
|
||||
checked: false,
|
||||
},
|
||||
];
|
||||
@tracked defaultpostmode: string = 'public';
|
||||
@tracked followapproval: boolean = false;
|
||||
]
|
||||
@tracked defaultpostmode: string = 'Public'
|
||||
@tracked followapproval: boolean = false
|
||||
// Actual custom properties stored in here
|
||||
@tracked customProperties: Array<{ key: string; value: string }> = [];
|
||||
@tracked indexable: boolean = true;
|
||||
@tracked customProperties: Array<{ key: string; value: string }> = []
|
||||
@tracked indexable: boolean = true
|
||||
@tracked mail = { mail: '', valid: false }
|
||||
|
||||
genderAddedHandler(newIndex: number) {
|
||||
console.log('gender added');
|
||||
console.log('gender added')
|
||||
}
|
||||
genderRemovedHandler(removedIndex: number) {
|
||||
console.log('gender removed');
|
||||
console.log('gender removed')
|
||||
}
|
||||
|
||||
@action test() {
|
||||
console.log(this.mail)
|
||||
}
|
||||
}
|
||||
|
|
11
frontend-reactive/app/components/util/mail-entry.hbs
Normal file
11
frontend-reactive/app/components/util/mail-entry.hbs
Normal file
|
@ -0,0 +1,11 @@
|
|||
<div class="mail-entry {{@wrapper-classes}}">
|
||||
<label>
|
||||
Email
|
||||
<Input @type="text" @value={{this.args.data.mail}} placeholder="Email address" {{on "change" (fn this.checkMail)}}/>
|
||||
</label>
|
||||
{{#if this.mailOk}}
|
||||
<p class="mail-ok">O</p>
|
||||
{{else}}
|
||||
<p class="mail-error">X</p>
|
||||
{{/if}}
|
||||
</div>
|
27
frontend-reactive/app/components/util/mail-entry.ts
Normal file
27
frontend-reactive/app/components/util/mail-entry.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { action } from '@ember/object'
|
||||
import { map } from '@ember/object/computed'
|
||||
import Component from '@glimmer/component'
|
||||
import { tracked } from '@glimmer/tracking'
|
||||
|
||||
const re = /.+@\S+\.\S+/
|
||||
|
||||
export interface UtilMailEntrySignature {
|
||||
// The arguments accepted by the component
|
||||
Args: {
|
||||
data: { mail: string; valid: boolean }
|
||||
}
|
||||
// Any blocks yielded by the component
|
||||
Blocks: {
|
||||
default: []
|
||||
}
|
||||
// The element to which `...attributes` is applied in the component template
|
||||
Element: null
|
||||
}
|
||||
|
||||
export default class UtilMailEntry extends Component<UtilMailEntrySignature> {
|
||||
@tracked mailOk = this.args.data.valid
|
||||
@action checkMail() {
|
||||
this.args.data.valid = re.test(this.args.data.mail)
|
||||
this.mailOk = this.args.data.valid
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
<div class="{{@wrapper-class}}">
|
||||
{{#each @elements as |element|}}
|
||||
{{#each @elements as |element index|}}
|
||||
<RadioButton
|
||||
@value="{{element}}"
|
||||
@groupValue={{@selected}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue