More work on post registration form

This commit is contained in:
Melody Becker 2024-10-28 16:33:17 +01:00
parent 952949b609
commit 8b03454d6f
27 changed files with 247 additions and 51 deletions

View file

@ -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;
}