ajout du package shajs et envoie du hash comme mot de passe
This commit is contained in:
Generated
+12203
-35
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user