Select Git revision
login.service.ts
Forked from an inaccessible project.
narindra.rajohnso authored
login.service.ts 1.37 KiB
import { Injectable } from '@angular/core';
import * as CryptoJS from 'crypto-js';
import {FormControl, FormGroup, Validators} from "@angular/forms";
export enum ErrorLogin {
PassConfirm ,
UserNameExist,
UserNotExist ,
UserPassword
}
@Injectable({
providedIn: 'root'
})
export class LoginService {
private _actualError!: ErrorLogin;
get actualError():ErrorLogin{
return this._actualError
}
set actualError(value: ErrorLogin){
this._actualError=value;
}
constructor() { }
hashPassword(password: string): string {
const hash = CryptoJS.SHA256(password);
return hash.toString(CryptoJS.enc.Base64);
}
formDataCreate():FormGroup{
return new FormGroup({
username: new FormControl(null, {
updateOn: 'change',
validators: [Validators.required],
}),
firstname: new FormControl(null, {
updateOn: 'change',
validators: [Validators.required],
}),
lastname: new FormControl(null, {
updateOn: 'change',
validators: [Validators.required],
}),
email: new FormControl(null, {
updateOn: 'change',
validators: [Validators.required],
}),
password: new FormControl(null, {
updateOn: 'change',
validators: [Validators.required],
}),
accountType: new FormControl("User", {
updateOn: 'change'
})
});
}
}