aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_modals/login-modal/login-modal.component.ts
blob: d17d70177c8035ad08dcb5d29d0902af8e7f2f51 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Component, OnInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { CookieService } from 'ngx-cookie-service';
import { AuthService } from 'src/app/_services/auth.service';

@Component({
  selector: 'app-login-modal',
  templateUrl: './login-modal.component.html',
  styleUrls: ['./login-modal.component.css']
})
export class LoginModalComponent implements OnInit {

  username: string = '';
  password: string = '';

  public wrongCreds: boolean = false;      //RAZMOTRITI

  constructor(
    private authService: AuthService,
    private cookie: CookieService,
    private router: Router
  ) { }

  ngOnInit(): void {
  }

  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
        console.log(response);
        this.authService.authenticate(response);
        (<HTMLSelectElement>document.getElementById('closeButton')).click();
      }, error => {
        console.warn(error); //NETACNI PODACI
      });
    }
    
  }
  resetData() {
    this.username = '';
    this.password = '';
  }
}