aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_pages/profile/profile.component.ts
diff options
context:
space:
mode:
authorOgnjen Cirkovic <ciraboxkg@gmail.com>2022-05-20 02:48:48 +0200
committerOgnjen Cirkovic <ciraboxkg@gmail.com>2022-05-20 02:48:48 +0200
commitecf9618c7d48d3d47fbcc21df230f12a1369940c (patch)
tree1ca71cf30795323756fb1a7d1d4e3ff2c8e90268 /frontend/src/app/_pages/profile/profile.component.ts
parente4222ce4533beb64bd8460a9d7c4ad3688220f56 (diff)
parent02416dee28e57181b1da03b7f5ce6cc538a9415a (diff)
Merge branch 'redesign' of http://gitlab.pmf.kg.ac.rs/igrannonica/neuronstellar into Redesign
Diffstat (limited to 'frontend/src/app/_pages/profile/profile.component.ts')
-rw-r--r--frontend/src/app/_pages/profile/profile.component.ts44
1 files changed, 24 insertions, 20 deletions
diff --git a/frontend/src/app/_pages/profile/profile.component.ts b/frontend/src/app/_pages/profile/profile.component.ts
index 3c81883e..aed8e40c 100644
--- a/frontend/src/app/_pages/profile/profile.component.ts
+++ b/frontend/src/app/_pages/profile/profile.component.ts
@@ -44,7 +44,7 @@ export class ProfileComponent implements OnInit {
wrongNewPass2Bool: 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}$/;
@@ -96,24 +96,26 @@ export class ProfileComponent implements OnInit {
if (this.user.username != editedUser.username) { //promenio username, ide logout
this.user = editedUser;
this.resetInfo();
- shared.openDialog("Obaveštenje", "Nakon promene korisničkog imena, moraćete ponovo da se ulogujete.");
- this.authService.logOut();
- this.router.navigate(['']);
- return;
- }
- shared.openDialog("Obaveštenje", "Podaci su uspešno promenjeni.");
- this.user = editedUser;
- this.resetInfo();
- }, (error: any) =>{
- if (error.error == "Username already exists!") {
const dialogRef = this.dialog?.open(AlertDialogComponent, {
width: '350px',
- data: { title: "Obaveštenje", message: "Ukucano korisničko ime je već zauzeto! Izaberite neko drugo." }
+ data: { title: "Obaveštenje", message: "Nakon promene korisničkog imena, moraćete ponovo da se ulogujete." }
});
dialogRef?.afterClosed().subscribe(res => {
- this.resetInfo();
+ this.authService.logOut();
+ this.router.navigate(['']);
+ return;
});
}
+ else {
+ shared.openDialog("Obaveštenje", "Podaci su uspešno promenjeni.");
+ this.user = editedUser;
+ this.resetInfo();
+ }
+ }, (error: any) =>{
+ if (error.error == "Username already exists!") {
+ shared.openDialog("Obaveštenje", "Ukucano korisničko ime je već zauzeto! Izaberite neko drugo.");
+ this.resetInfo();
+ }
});
}
@@ -126,12 +128,10 @@ export class ProfileComponent implements OnInit {
if (this.newPass1 == '' && this.newPass2 == '') //ne zeli da promeni lozinku
return;
- //console.log("zeli da promeni lozinku");
if (this.newPass1 != this.newPass2) { //netacno ponovio novu lozinku
this.wrongNewPassBool = true;
this.resetNewPassInputs();
- //console.log("Netacno ponovljena lozinka");
return;
}
@@ -139,19 +139,23 @@ export class ProfileComponent implements OnInit {
this.userInfoService.changeUserPassword(passwordArray).subscribe((response: any) => {
//console.log("PROMENIO LOZINKU");
this.resetNewPassInputs();
- shared.openDialog("Obaveštenje", "Nakon promene lozinke, moraćete ponovo da se ulogujete.");
- this.authService.logOut();
- this.router.navigate(['']);
+ const dialogRef = this.dialog?.open(AlertDialogComponent, {
+ width: '350px',
+ data: { title: "Obaveštenje", message: "Nakon promene lozinke, moraćete ponovo da se ulogujete." }
+ });
+ dialogRef?.afterClosed().subscribe(res => {
+ this.authService.logOut();
+ this.router.navigate(['']);
+ return;
+ });
}, (error: any) => {
if (error.error == 'Wrong old password!') {
this.wrongPassBool = true;
- //(<HTMLSelectElement>document.getElementById("inputPassword")).focus();
return;
}
else if (error.error == 'Identical password!') {
shared.openDialog("Obaveštenje", "Stara i nova lozinka su identične.");
this.resetNewPassInputs();
- //(<HTMLSelectElement>document.getElementById("inputNewPassword")).focus();
return;
}
});