Update: Add frontend
This commit is contained in:
parent
be5bfa1fb5
commit
3d3b5fc51e
76 changed files with 17761 additions and 1 deletions
77
frontend/src/app/login/page-login/page-login.component.ts
Normal file
77
frontend/src/app/login/page-login/page-login.component.ts
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import {Component} from '@angular/core';
|
||||
import {Router} from "@angular/router";
|
||||
import {MessageService} from "../../common/services/message/message.service";
|
||||
import {HashageService} from "../../common/services/hashage/hashage.service";
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-page-login',
|
||||
templateUrl: './page-login.component.html',
|
||||
styleUrls: ['./page-login.component.scss']
|
||||
})
|
||||
export class PageLoginComponent
|
||||
{
|
||||
email: string = "" ;
|
||||
password: string = "" ;
|
||||
hasError: boolean = false;
|
||||
errorMessage: string = "";
|
||||
|
||||
|
||||
constructor( private messageService: MessageService,
|
||||
private router: Router,
|
||||
private hashageService: HashageService ) { }
|
||||
|
||||
|
||||
// Appuie sur le bouton "seConnecter"
|
||||
onSeConnecter(): void
|
||||
{
|
||||
this.checkField();
|
||||
if(!this.hasError)
|
||||
{
|
||||
let data = {
|
||||
email: this.email,
|
||||
hashPass: this.hashageService.run(this.password)
|
||||
};
|
||||
console.log(data);
|
||||
/*
|
||||
this.messageService
|
||||
.sendMessage('user/auth', data)
|
||||
.subscribe( retour => this.callbackSeConnecter(retour))
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Callback de "onSeConnecter"
|
||||
callbackSeConnecter(retour: any): void
|
||||
{
|
||||
if(retour.status !== 200)
|
||||
{
|
||||
this.errorMessage = retour.error.data.reason;
|
||||
this.hasError = true;
|
||||
}
|
||||
else {
|
||||
//this.router.navigateByUrl( '/search' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check les champs saisis par l'utilisateur
|
||||
checkField(): void
|
||||
{
|
||||
if(this.email === "") {
|
||||
this.errorMessage = "Veuillez remplir le champ email" ;
|
||||
this.hasError = true;
|
||||
}
|
||||
else if(this.password === "") {
|
||||
this.errorMessage = "Veuillez remplir le champ mot de passe" ;
|
||||
this.hasError = true;
|
||||
}
|
||||
else {
|
||||
this.errorMessage = "" ;
|
||||
this.hasError = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue