diff options
author | TAMARA JERINIC <tamara.jerinic@gmail.com> | 2022-03-09 22:19:17 +0100 |
---|---|---|
committer | TAMARA JERINIC <tamara.jerinic@gmail.com> | 2022-03-09 22:19:17 +0100 |
commit | cbdc861b07e82502664f1c849f141a51104cd3d0 (patch) | |
tree | 9959995ea265df2d0be6ff307838a957b813f88e /frontend/src/app/_pages/login-page/login-page.component.ts | |
parent | 8e7f2346cc4507b7e8056b57e01c0e85c11a4a2c (diff) | |
parent | a95a921478435cc6400236d291281c3d0156a7e1 (diff) |
Merge branch 'dev' of http://gitlab.pmf.kg.ac.rs/igrannonica/neuronstellar into microservice
Diffstat (limited to 'frontend/src/app/_pages/login-page/login-page.component.ts')
-rw-r--r-- | frontend/src/app/_pages/login-page/login-page.component.ts | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/frontend/src/app/_pages/login-page/login-page.component.ts b/frontend/src/app/_pages/login-page/login-page.component.ts new file mode 100644 index 00000000..f8b429e3 --- /dev/null +++ b/frontend/src/app/_pages/login-page/login-page.component.ts @@ -0,0 +1,40 @@ +import { Component, OnInit } from '@angular/core'; +import { CookieService } from 'ngx-cookie-service'; +import { AuthService } from 'src/app/_services/auth.service'; + +@Component({ + selector: 'app-login-page', + templateUrl: './login-page.component.html', + styleUrls: ['./login-page.component.css'] +}) +export class LoginPageComponent implements OnInit { + email: string = ''; + password: string = ''; + + public wrongCreds: boolean = false; //RAZMOTRITI + //public notApproved: boolean = false; //RAZMOTRITI + + pattEmail: RegExp = /^[a-zA-Z0-9]+([\.\-\+][a-zA-Z0-9]+)*\@([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}$/; + + constructor( + private authService: AuthService, + private cookie: CookieService + ) { } + + ngOnInit(): void { + } + + onSubmit() { + if (!this.pattEmail.test(this.email)) { + console.warn('Bad email!'); + return; + } + else { + this.authService.login(this.email, this.password).subscribe((response) => { + console.log(response); + this.cookie.set('token', response); + }) + } + } + +} |