aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/signup/signup.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src/app/components/signup/signup.component.ts')
-rw-r--r--ufund-ui/src/app/components/signup/signup.component.ts29
1 files changed, 20 insertions, 9 deletions
diff --git a/ufund-ui/src/app/components/signup/signup.component.ts b/ufund-ui/src/app/components/signup/signup.component.ts
index 48c6387..10fbce5 100644
--- a/ufund-ui/src/app/components/signup/signup.component.ts
+++ b/ufund-ui/src/app/components/signup/signup.component.ts
@@ -2,6 +2,7 @@ import { Component } from '@angular/core';
import {UsersService} from '../../services/users.service';
import {Router} from '@angular/router';
import {BehaviorSubject} from 'rxjs';
+import {Need} from '../../models/Need';
@Component({
selector: 'app-signup',
@@ -13,8 +14,11 @@ export class SignupComponent {
protected statusText = new BehaviorSubject("")
protected showSuccessMessage = new BehaviorSubject(false)
- protected passwordStrength = new BehaviorSubject("")
+ protected passwordStrongEnough = new BehaviorSubject(true)
+ passwordRequirements: String[] = [("❌ Password length"), ("❌ Lowercase letters")];
protected strength = new BehaviorSubject(0)
+ protected color = new BehaviorSubject("red")
+ protected test = new BehaviorSubject("Password does not meet requirements")
constructor(
protected usersService: UsersService,
@@ -36,7 +40,12 @@ export class SignupComponent {
}
checkPasswordStrength(password: string) {
+ this.passwordRequirements = [("❌ Password length"), ("❌ Lowercase letters")];
+ this.test.next("Password does not meet requirements")
this.statusText.next("")
+ this.passwordStrongEnough.next(true)
+ this.color.next("red")
+
if (password.match(/[^!-~]/g)) {
this.statusText.next("Invalid characters")
return
@@ -45,32 +54,34 @@ export class SignupComponent {
let strength = 0;
if (password.length > 6) {
strength++
- console.log("Long")
+ this.passwordRequirements[0] = "✅ Password length"
+ this.color.next("green")
}
if (password.length > 12) {
strength++
- console.log("Longer")
}
if (password.match(/[a-z]/g)) {
strength++
- console.log("a")
}
- if (password.match(/[0-9]/g)) {
+ if (password.match(/[A-Z]/g)) {
strength++
- console.log("0")
}
- if (password.match(/[A-Z]/g)) {
+ if (password.match(/[0-9]/g)) {
strength++
- console.log("A")
}
if (password.match(/[!-/]/g)) {
strength++
- console.log("!")
+ }
+
+ if (strength >= 5) {
+ this.passwordStrongEnough.next(false)
+ this.test.next("")
}
this.strength.next(strength)
}
+ protected readonly length = length;
}
let friendlyHttpStatus: {[key: number]: string} = {