aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_modals
diff options
context:
space:
mode:
authorSonja Galovic <galovicsonja@gmail.com>2022-03-21 19:14:19 +0100
committerSonja Galovic <galovicsonja@gmail.com>2022-03-21 19:14:19 +0100
commit31642f68564e67175301235546b74baf56ac5882 (patch)
tree67e227491da5217d1a5bd572a2e66f031eb68731 /frontend/src/app/_modals
parenta77c7bff39574428953c162b17d4dee1113e68f7 (diff)
Register - nakon uspesne registracije, korisnik je automatski ulogovan. Login - obavestenje o netacnim podacima.
Diffstat (limited to 'frontend/src/app/_modals')
-rw-r--r--frontend/src/app/_modals/login-modal/login-modal.component.html10
-rw-r--r--frontend/src/app/_modals/login-modal/login-modal.component.ts23
-rw-r--r--frontend/src/app/_modals/register-modal/register-modal.component.html2
-rw-r--r--frontend/src/app/_modals/register-modal/register-modal.component.ts16
4 files changed, 33 insertions, 18 deletions
diff --git a/frontend/src/app/_modals/login-modal/login-modal.component.html b/frontend/src/app/_modals/login-modal/login-modal.component.html
index d694ea58..d7836848 100644
--- a/frontend/src/app/_modals/login-modal/login-modal.component.html
+++ b/frontend/src/app/_modals/login-modal/login-modal.component.html
@@ -20,12 +20,12 @@
<input [(ngModel)]="password" name="password" type="password" id="password"
class="form-control form-control" placeholder="Unesite lozinku..." />
</div>
-
- <div class="text-center text-lg-start mt-5 pt-2">
- <p *ngIf="wrongCreds" class="small fw-bold mt-2 pt-1 mb-0 text-danger">Lozinka ili e-mail su pogrešni
- </p>
- </div>
</form>
+
+ <div class="text-center text-lg-start mt-5">
+ <p *ngIf="wrongCreds" class="small fw-bold text-danger text-center">Unesite ispravan e-mail i lozinku.</p>
+ </div>
+
<div class="col-md-12 d-flex justify-content-center">
<button type="button" class="btn btn-lg" style="color:white; background-color: #003459; margin-right: 10px;" (click)="doLogin()">Prijavite se</button>
<button type="button" class="btn btn-lg btn-outline-secondary" data-bs-dismiss="modal" (click)="resetData()">Odustanite</button>
diff --git a/frontend/src/app/_modals/login-modal/login-modal.component.ts b/frontend/src/app/_modals/login-modal/login-modal.component.ts
index d17d7017..1b634c9a 100644
--- a/frontend/src/app/_modals/login-modal/login-modal.component.ts
+++ b/frontend/src/app/_modals/login-modal/login-modal.component.ts
@@ -13,7 +13,7 @@ export class LoginModalComponent implements OnInit {
username: string = '';
password: string = '';
- public wrongCreds: boolean = false; //RAZMOTRITI
+ wrongCreds: boolean = false;
constructor(
private authService: AuthService,
@@ -26,17 +26,26 @@ export class LoginModalComponent implements OnInit {
doLogin() {
if (this.username.length > 0 && this.password.length > 0) {
- this.authService.login(this.username, this.password).subscribe((response) => { //ako nisu ok podaci, ne ide hide nego mora opet da ukucava!!!!podesi
+ this.authService.login(this.username, this.password).subscribe((response) => {
console.log(response);
- this.authService.authenticate(response);
- (<HTMLSelectElement>document.getElementById('closeButton')).click();
- }, error => {
- console.warn(error); //NETACNI PODACI
+
+ if (response == "Username doesn't exist" || response == "Wrong password") {
+ this.wrongCreds = true;
+ this.password = '';
+ }
+ else {
+ this.authService.authenticate(response);
+ (<HTMLSelectElement>document.getElementById('closeButton')).click();
+ }
});
}
-
+ else {
+ this.wrongCreds = true;
+ this.password = '';
+ }
}
resetData() {
+ this.wrongCreds = false;
this.username = '';
this.password = '';
}
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 7098c040..68025a46 100644
--- a/frontend/src/app/_modals/register-modal/register-modal.component.html
+++ b/frontend/src/app/_modals/register-modal/register-modal.component.html
@@ -4,7 +4,7 @@
<div class="modal-dialog modal-dialog-centered modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" style="background-color: #003459;">
- <button type="button" class="btn-close" data-bs-dismiss="modal" style="background-color: white;"
+ <button id="closeButtonReg" type="button" class="btn-close" data-bs-dismiss="modal" style="background-color: white;"
aria-label="Close" (click)="resetData()"></button>
</div>
<div class="modal-body" style="color:#003459">
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 c02a4e1a..c045f1ce 100644
--- a/frontend/src/app/_modals/register-modal/register-modal.component.ts
+++ b/frontend/src/app/_modals/register-modal/register-modal.component.ts
@@ -136,15 +136,21 @@ export class RegisterModalComponent implements OnInit {
.subscribe(
(response) => {
console.log(response);
- if (response === 'User added') {
- this.resetData();
- (<HTMLSelectElement>document.getElementById('linkToLoginModal')).click();
+ if (response == 'User added') {
+ //nakon sto je registrovan, nek bude ulogovan
+ this.authService.login(this.username, this.pass1).subscribe((response) => {
+
+ this.authService.authenticate(response);
+ console.log("close button");
+ (<HTMLSelectElement>document.getElementById('closeButtonReg')).click();
+ //(<HTMLSelectElement>document.getElementById('linkToLoginModal')).click();
+ }, (error) => console.warn(error));
}
- else if (response === 'Email Already Exists') {
+ else if (response == 'Email Already Exists') {
alert('Nalog sa unetim email-om već postoji!');
(<HTMLSelectElement>document.getElementById('email')).focus();
}
- else if (response === 'Username Already Exists') {
+ else if (response == 'Username Already Exists') {
alert('Nalog sa unetim korisničkim imenom već postoji!');
(<HTMLSelectElement>document.getElementById('username-register')).focus();
}