ajout du package shajs et envoie du hash comme mot de passe

This commit is contained in:
Vincent BENOIT committed 2022-10-06 17:48:05 +02:00
1 parent fb47267030
commit 7c836984dd
4 files changed
+12228 -36

No files matched your search

@@ -3,6 +3,7 @@ import { FormBuilder, FormGroup, Validators, ValidatorFn, ValidationErrors, Abst
import { Router } from '@angular/router';
import { BackendService } from '../../../../services/backend/backend.service';
import { ToastrService } from 'ngx-toastr';
const shajs = require('sha.js');
@Component({
selector: 'app-account',
@@ -14,6 +15,7 @@ export class AccountComponent implements OnInit {
submitted:boolean=false;
minPw:number = 8;
maxPw:number = 24;
hash:string = '';
constructor(private fb:FormBuilder,
private bs:BackendService,
@@ -36,7 +38,16 @@ export class AccountComponent implements OnInit {
}
onUpdate(): void {
if(this.passwdFG.invalid) {
return;
}
this.hash = shajs('sha256').update(this.passwdFG.get('new_passwd').value()).digest('hex');
this.bs.updatePasswd(this.hash).subscribe(
data => {
this.toast.success("Mise à jour réussie");
}, error => {
this.toast.error("Erreur de mise à jour du mot de passe");
});
}
}
@@ -55,4 +55,16 @@ export class BackendService {
};
return this.http.get<Utilisateur>(host+"/api/configurateur/current", options);
}
updatePasswd(val:any):Observable<any> {
let host=environment.host;
const options = {
headers: new HttpHeaders({
'Content-Type' : 'application/json',
}),
withCredentials: true
};
return this.http.post<any>(host+"/api/configurateur/update_passwd", val, options);
}
}