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

This commit is contained in:
Vincent BENOIT
2022-10-06 17:48:05 +02:00
parent fb47267030
commit 7c836984dd
4 changed files with 12228 additions and 36 deletions
+12203 -35
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -29,6 +29,7 @@
"material-icons": "^1.12.0",
"ngx-toastr": "^14.3.0",
"rxjs": "~7.5.0",
"sha.js": "^2.4.11",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
@@ -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);
}
}