Correction autour de l'administrateur

This commit is contained in:
Sébastien André
2021-03-18 16:32:10 +01:00
parent 733e85507a
commit beee601a57
7 changed files with 25 additions and 15 deletions

View File

@@ -38,7 +38,7 @@ export class AuthenticationService extends BaseService {
bodyLogin,
{ headers: this.headers })
.pipe(map(user => {
this.pushUserToken(username, password, user);
this.pushToken(username, password, user);
return user;
}));
}
@@ -48,12 +48,22 @@ export class AuthenticationService extends BaseService {
newUser,
{ headers: this.headers })
.pipe(map(user => {
this.pushUserToken(newUser.login, newUser.password, user);
this.pushToken(newUser.login, newUser.password, user);
return user;
}));
}
private pushUserToken(login: string, password: string, user: User){
public update(updatedUser: User) {
return this.http.put<User>(`${this.apiUrl}/User/${updatedUser.id}`,
updatedUser,
{ headers: this.headers })
.pipe(map(user => {
this.pushToken(updatedUser.login, updatedUser.password, user);
return user;
}));
}
private pushToken(login: string, password: string, user: User){
if (user && user.token) {
user.authdata = window.btoa(login + ":" + password);
localStorage.setItem("currentUser", JSON.stringify(user));