diff options
author | Sonja Galovic <galovicsonja@gmail.com> | 2022-05-16 17:14:00 +0200 |
---|---|---|
committer | Sonja Galovic <galovicsonja@gmail.com> | 2022-05-16 17:14:00 +0200 |
commit | cebddfe818f0519b3f57ef65c619d7d1d81783f7 (patch) | |
tree | 5a6ff57c6c3dc561ac3a6ae5f44686960cb45c6c /frontend/src/app/_modals/register-modal | |
parent | c544d2a84b4bd922bcd4be9fd789035e1d5d9dcc (diff) |
Registracija: resen problem da jedan popup zakloni drugi (obavestenje ispod polja). Izmene u column-table.
Diffstat (limited to 'frontend/src/app/_modals/register-modal')
-rw-r--r-- | frontend/src/app/_modals/register-modal/register-modal.component.html | 2 | ||||
-rw-r--r-- | frontend/src/app/_modals/register-modal/register-modal.component.ts | 21 |
2 files changed, 17 insertions, 6 deletions
diff --git a/frontend/src/app/_modals/register-modal/register-modal.component.html b/frontend/src/app/_modals/register-modal/register-modal.component.html index 0c791a61..5182198c 100644 --- a/frontend/src/app/_modals/register-modal/register-modal.component.html +++ b/frontend/src/app/_modals/register-modal/register-modal.component.html @@ -33,6 +33,7 @@ <mat-icon matSuffix></mat-icon> </mat-form-field> <p *ngIf="wrongUsernameBool" class="wrong-creds">Unesite ispravno korisničko ime.</p> + <p *ngIf="usernameAlreadyExistsBool" class="wrong-creds">Uneto korisničko ime je zauzeto.</p> </div> <!--Email--> <div> @@ -42,6 +43,7 @@ <mat-icon matSuffix></mat-icon> </mat-form-field> <p *ngIf="wrongEmailBool" class="wrong-creds">Unesite ispravno e-mail adresu.</p> + <p *ngIf="emailAlreadyExistsBool" class="wrong-creds">Uneta e-mail adresa je zauzeta.</p> </div> <!-- Lozinka 1. --> <div> diff --git a/frontend/src/app/_modals/register-modal/register-modal.component.ts b/frontend/src/app/_modals/register-modal/register-modal.component.ts index a5c6ddc6..b1129668 100644 --- a/frontend/src/app/_modals/register-modal/register-modal.component.ts +++ b/frontend/src/app/_modals/register-modal/register-modal.component.ts @@ -25,9 +25,11 @@ export class RegisterModalComponent implements OnInit { wrongEmailBool: boolean = false; wrongPass1Bool: boolean = false; wrongPass2Bool: boolean = false; + usernameAlreadyExistsBool: boolean = false; + emailAlreadyExistsBool: boolean = false; pattName: RegExp = /^[a-zA-ZšŠđĐčČćĆžŽ]+([ \-][a-zA-ZšŠđĐčČćĆžŽ]+)*$/; - pattUsername: RegExp = /^[a-zA-Z0-9]{6,18}$/; + pattUsername: RegExp = /^[a-zA-Z0-9]{4,18}$/; pattTwoSpaces: RegExp = / /; pattEmail: RegExp = /^[a-zA-Z0-9]+([\.\-\+][a-zA-Z0-9]+)*\@([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}$/; pattPassword: RegExp = /.{6,30}$/; @@ -59,7 +61,7 @@ export class RegisterModalComponent implements OnInit { } resetData() { this.firstName = this.lastName = this.username = this.email = this.pass1 = this.pass2 = ''; - this.wrongFirstNameBool = this.wrongLastNameBool = this.wrongUsernameBool = this.wrongEmailBool = this.wrongPass1Bool = this.wrongPass2Bool = false; + this.wrongFirstNameBool = this.wrongLastNameBool = this.wrongUsernameBool = this.wrongEmailBool = this.wrongPass1Bool = this.wrongPass2Bool = this.usernameAlreadyExistsBool = this.emailAlreadyExistsBool = false; this.password1Shown = false; this.password2Shown = false; } @@ -160,10 +162,13 @@ export class RegisterModalComponent implements OnInit { dateCreated:new Date() } + this.authService.register(user) .subscribe( (response) => { if (response == 'User added') { + this.usernameAlreadyExistsBool = false; + this.emailAlreadyExistsBool = false; //nakon sto je registrovan, nek bude ulogovan this.authService.login(this.username, this.pass1).subscribe((response) => { @@ -174,12 +179,16 @@ export class RegisterModalComponent implements OnInit { }, (error) => console.warn(error)); } else if (response == 'Email Already Exists') { - shared.openDialog("Greška!", "Nalog sa unetim email-om već postoji!"); - (<HTMLSelectElement>document.getElementById('email')).focus(); + /*shared.openDialog("Greška!", "Nalog sa unetim email-om već postoji!"); + (<HTMLSelectElement>document.getElementById('email')).focus();*/ + this.usernameAlreadyExistsBool = false; + this.emailAlreadyExistsBool = true; } else if (response == 'Username Already Exists') { - shared.openDialog("Greška!", "Nalog sa unetim korisničkim imenom već postoji!"); - (<HTMLSelectElement>document.getElementById('username-register')).focus(); + /*shared.openDialog("Greška!", "Nalog sa unetim korisničkim imenom već postoji!"); + (<HTMLSelectElement>document.getElementById('username-register')).focus();*/ + this.emailAlreadyExistsBool = false; + this.usernameAlreadyExistsBool = true; } } ); |