diff options
Diffstat (limited to 'ufund-ui/src/app/components/signup/signup.component.ts')
-rw-r--r-- | ufund-ui/src/app/components/signup/signup.component.ts | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/ufund-ui/src/app/components/signup/signup.component.ts b/ufund-ui/src/app/components/signup/signup.component.ts index a20d828..9c37211 100644 --- a/ufund-ui/src/app/components/signup/signup.component.ts +++ b/ufund-ui/src/app/components/signup/signup.component.ts @@ -3,10 +3,10 @@ import {UsersService} from '../../services/users.service'; import {Router} from '@angular/router'; import {BehaviorSubject} from 'rxjs'; import {ToastsService, ToastType} from '../../services/toasts.service'; +import {AuthService} from '../../services/auth.service'; class PasswordRequirements { sixLong: {title: string, value: boolean} = {title: 'Is 6 characters or longer' , value: false} - twelveLong: {title: string, value: boolean} = {title: 'Is 12 characters or longer', value: false} lowercase: {title: string, value: boolean} = {title: 'Includes lowercase letter' , value: false} uppercase: {title: string, value: boolean} = {title: 'Includes uppercase letter' , value: false} number: {title: string, value: boolean} = {title: 'Includes number' , value: false} @@ -25,17 +25,16 @@ export class SignupComponent { protected passwordStatusText = new BehaviorSubject("") protected passwordsMatch = new BehaviorSubject(false) protected usernameStatusText = new BehaviorSubject("") - protected showSuccessMessage = new BehaviorSubject(false) protected passwordStrongEnough = new BehaviorSubject(false) protected ableToCreateAccount = new BehaviorSubject(false) protected passwordRequirements: PasswordRequirements = new PasswordRequirements() protected strength = new BehaviorSubject(0) - protected statusText = new BehaviorSubject(""); constructor( protected usersService: UsersService, protected router: Router, - protected toastService: ToastsService + protected toastService: ToastsService, + protected authService: AuthService ) {} signup(username: string | null, password: string | null) { @@ -45,7 +44,10 @@ export class SignupComponent { } this.usersService.createUser(username, password).then(() => { - this.showSuccessMessage.next(true); + // let action = {label: 'Proceed to login', onAction: () => this.router.navigate(["/login"])} + this.toastService.sendToast(ToastType.INFO, "Account successfully created") + this.authService.login(username, password) + this.router.navigate(["/"]) }).catch(ex => { this.toastService.sendToast(ToastType.ERROR, "Unable to create account: " + friendlyHttpStatus[ex.status]) console.log(ex) @@ -74,16 +76,12 @@ export class SignupComponent { if (password.match(/[^!-~]/g)) { this.passwordStatusText.next("Invalid characters") - return } if (password.length > 6) { this.passwordRequirements.sixLong.value = true } - if (password.length > 12) { - this.passwordRequirements.twelveLong.value = true - } if (password.match(/[a-z]/g)) { this.passwordRequirements.lowercase.value = true } @@ -108,7 +106,7 @@ export class SignupComponent { } else if (strength == 0) { this.passwordStatusText.next("") } else { - this.passwordStatusText.next("5/6 checks required") + this.passwordStatusText.next("Password must meet requirements") } this.strength.next(strength) |