|
|
|
@ -14,6 +14,8 @@ export class RegisterComponent implements OnInit {
|
|
|
|
|
errorMessage: string;
|
|
|
|
|
hide1 = true;
|
|
|
|
|
hide2 = true;
|
|
|
|
|
ageCheck = false;
|
|
|
|
|
imprintCheck = false;
|
|
|
|
|
|
|
|
|
|
constructor(private registerService: RegisterService) {
|
|
|
|
|
this.registration = {username: null, passwordHash: null, email: null};
|
|
|
|
@ -28,7 +30,7 @@ export class RegisterComponent implements OnInit {
|
|
|
|
|
onClickSubmit(pUsername: string, pEmail: string, pPasswordHash: string, pPasswordHashRepeat: string) {
|
|
|
|
|
this.errorOccurred = false;
|
|
|
|
|
this.errorMessage = ' ';
|
|
|
|
|
if (this.passwordSame(pPasswordHash, pPasswordHashRepeat)) {
|
|
|
|
|
if (this.passwordSame(pPasswordHash, pPasswordHashRepeat) && this.boxesChecked()) {
|
|
|
|
|
this.registration.username = pUsername.trim();
|
|
|
|
|
this.registration.email = pEmail.trim().toLowerCase();
|
|
|
|
|
this.registration.passwordHash = sha512.sha512(pPasswordHash);
|
|
|
|
@ -38,7 +40,6 @@ export class RegisterComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
passwordSame(pwd: string, pwd2: string) {
|
|
|
|
|
if (pwd === pwd2) {
|
|
|
|
|
console.log('password same');
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
this.errorOccurred = true;
|
|
|
|
@ -47,6 +48,21 @@ export class RegisterComponent implements OnInit {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boxesChecked(): boolean {
|
|
|
|
|
if (this.imprintCheck && this.ageCheck) {
|
|
|
|
|
console.log('all boxes checked');
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
this.errorOccurred = true;
|
|
|
|
|
if (!this.ageCheck) {
|
|
|
|
|
this.errorMessage = 'You have to confirm your age.';
|
|
|
|
|
} else if (!this.imprintCheck) {
|
|
|
|
|
this.errorMessage = 'You have to confirm that you read the privacy policy.';
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|