Correction autour de l'administrateur
This commit is contained in:
@@ -7,6 +7,6 @@ by editing this MSBuild file. In order to learn more about this please visit htt
|
||||
<PropertyGroup>
|
||||
<TimeStampOfAssociatedLegacyPublishXmlFile />
|
||||
<_PublishTargetUrl>C:\Projects\SkydiveLogs\Back\dist</_PublishTargetUrl>
|
||||
<History>True|2021-03-18T13:10:46.8227017Z;True|2021-03-15T15:33:07.2658649+01:00;</History>
|
||||
<History>True|2021-03-18T15:30:10.7797171Z;True|2021-03-18T14:10:46.8227017+01:00;True|2021-03-15T15:33:07.2658649+01:00;</History>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -26,7 +26,7 @@ export class ListOfAircraftsComponent implements OnInit {
|
||||
private serviceComm: ServiceComm,
|
||||
private authenticationService: AuthenticationService,
|
||||
public dialog: MatDialog) {
|
||||
this.isUserAdmin = this.authenticationService.currentUserValue.IsAdmin;
|
||||
this.isUserAdmin = this.authenticationService.currentUserValue.roles === "admin";
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@@ -32,7 +32,7 @@ export class ListOfDzsComponent implements OnInit {
|
||||
private serviceComm: ServiceComm,
|
||||
private authenticationService: AuthenticationService,
|
||||
public dialog: MatDialog) {
|
||||
this.isUserAdmin = this.authenticationService.currentUserValue.IsAdmin;
|
||||
this.isUserAdmin = this.authenticationService.currentUserValue.roles === "admin";
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@@ -26,7 +26,7 @@ export class ListOfJumpTypesComponent implements OnInit {
|
||||
private serviceComm: ServiceComm,
|
||||
private authenticationService: AuthenticationService,
|
||||
public dialog: MatDialog) {
|
||||
this.isUserAdmin = this.authenticationService.currentUserValue.IsAdmin;
|
||||
this.isUserAdmin = this.authenticationService.currentUserValue.roles === "admin";
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@@ -49,13 +49,11 @@ export class UserProfileComponent implements OnInit {
|
||||
return;
|
||||
}
|
||||
|
||||
const updatedUser = new User();
|
||||
updatedUser.login = formData.username;
|
||||
updatedUser.password = formData.password;
|
||||
updatedUser.firstName = formData.firstname;
|
||||
updatedUser.lastName = formData.lastname;
|
||||
updatedUser.email = formData.email;
|
||||
// const updatedUser = new User();
|
||||
// updatedUser.firstName = formData.firstName;
|
||||
// updatedUser.lastName = formData.lastName;
|
||||
// updatedUser.email = formData.email;
|
||||
|
||||
this.authenticationService.create(updatedUser);
|
||||
// this.authenticationService.update(updatedUser);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,5 +9,7 @@ export class User {
|
||||
authdata?: string;
|
||||
token?: string;
|
||||
|
||||
get IsAdmin() { return this.roles === "admin"; }
|
||||
public get isAdmin(): boolean {
|
||||
return this.roles === "admin";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user