third commit
This commit is contained in:
parent
87d97cf4fa
commit
18600e2874
8 changed files with 184 additions and 281 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {Observable} from "rxjs";
|
||||
import {JSdata, MessageService} from "../message/message.service";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
|
||||
|
||||
|
||||
|
|
@ -10,74 +12,31 @@ import {Observable} from "rxjs";
|
|||
export class AuthService {
|
||||
|
||||
// @ts-ignore
|
||||
public roomId: string;
|
||||
// @ts-ignore
|
||||
public name: string;
|
||||
// @ts-ignore
|
||||
public login: string;
|
||||
islog: boolean;
|
||||
|
||||
// @ts-ignore
|
||||
public showScreen: boolean;
|
||||
|
||||
// @ts-ignore
|
||||
public password: string;
|
||||
// @ts-ignore
|
||||
public currentUser;
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private MS: MessageService
|
||||
) {}
|
||||
|
||||
public userList = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Yuki Vachot',
|
||||
login: 'yuki',
|
||||
password: 'vachot1',
|
||||
roomId: {
|
||||
2: 'room-1',
|
||||
3: 'room-2',
|
||||
4: 'room-3'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Wilfried Vallee',
|
||||
login: 'wilfried',
|
||||
password: 'vallee2',
|
||||
roomId: {
|
||||
1: 'room-1',
|
||||
3: 'room-4',
|
||||
4: 'room-5'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Khai Phan',
|
||||
login: 'khai',
|
||||
password: 'phan3',
|
||||
roomId: {
|
||||
1: 'room-2',
|
||||
2: 'room-4',
|
||||
4: 'room-6'
|
||||
}
|
||||
sendAuthentication(login: string, password: string): Observable<JSdata> {
|
||||
const data = new FormData();
|
||||
if (login !== null && login !== undefined && password !== null && password !== undefined) {
|
||||
data.append(login, password);
|
||||
}
|
||||
];
|
||||
|
||||
constructor() {}
|
||||
|
||||
sendAuthentication(login:string, password: string): boolean {
|
||||
this.login = login;
|
||||
this.password = password;
|
||||
this.currentUser = this.userList.find(user => user.password === this.password.toString());
|
||||
this.userList = this.userList.filter((user) => user.password !== this.password.toString());
|
||||
if(this.currentUser) {
|
||||
this.showScreen = true;
|
||||
} else {
|
||||
console.log("Password Error", this.password.toString());
|
||||
}
|
||||
return this.showScreen ;
|
||||
return this.MS.sendMessage('checkLogin', {
|
||||
login : login,
|
||||
Password: password
|
||||
});
|
||||
}
|
||||
|
||||
sendAuth(password: string): any {
|
||||
this.password = password;
|
||||
return this.currentUser ;
|
||||
finalizeAuthentication(data: JSdata): void{
|
||||
if (data.status === 'ok') {
|
||||
this.islog = true;
|
||||
} else {
|
||||
this.islog = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue