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>
|
<PropertyGroup>
|
||||||
<TimeStampOfAssociatedLegacyPublishXmlFile />
|
<TimeStampOfAssociatedLegacyPublishXmlFile />
|
||||||
<_PublishTargetUrl>C:\Projects\SkydiveLogs\Back\dist</_PublishTargetUrl>
|
<_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>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -26,7 +26,7 @@ export class ListOfAircraftsComponent implements OnInit {
|
|||||||
private serviceComm: ServiceComm,
|
private serviceComm: ServiceComm,
|
||||||
private authenticationService: AuthenticationService,
|
private authenticationService: AuthenticationService,
|
||||||
public dialog: MatDialog) {
|
public dialog: MatDialog) {
|
||||||
this.isUserAdmin = this.authenticationService.currentUserValue.IsAdmin;
|
this.isUserAdmin = this.authenticationService.currentUserValue.roles === "admin";
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export class ListOfDzsComponent implements OnInit {
|
|||||||
private serviceComm: ServiceComm,
|
private serviceComm: ServiceComm,
|
||||||
private authenticationService: AuthenticationService,
|
private authenticationService: AuthenticationService,
|
||||||
public dialog: MatDialog) {
|
public dialog: MatDialog) {
|
||||||
this.isUserAdmin = this.authenticationService.currentUserValue.IsAdmin;
|
this.isUserAdmin = this.authenticationService.currentUserValue.roles === "admin";
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export class ListOfJumpTypesComponent implements OnInit {
|
|||||||
private serviceComm: ServiceComm,
|
private serviceComm: ServiceComm,
|
||||||
private authenticationService: AuthenticationService,
|
private authenticationService: AuthenticationService,
|
||||||
public dialog: MatDialog) {
|
public dialog: MatDialog) {
|
||||||
this.isUserAdmin = this.authenticationService.currentUserValue.IsAdmin;
|
this.isUserAdmin = this.authenticationService.currentUserValue.roles === "admin";
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|||||||
@@ -49,13 +49,11 @@ export class UserProfileComponent implements OnInit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedUser = new User();
|
// const updatedUser = new User();
|
||||||
updatedUser.login = formData.username;
|
// updatedUser.firstName = formData.firstName;
|
||||||
updatedUser.password = formData.password;
|
// updatedUser.lastName = formData.lastName;
|
||||||
updatedUser.firstName = formData.firstname;
|
// updatedUser.email = formData.email;
|
||||||
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;
|
authdata?: string;
|
||||||
token?: 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,
|
bodyLogin,
|
||||||
{ headers: this.headers })
|
{ headers: this.headers })
|
||||||
.pipe(map(user => {
|
.pipe(map(user => {
|
||||||
this.pushUserToken(username, password, user);
|
this.pushToken(username, password, user);
|
||||||
return user;
|
return user;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -48,12 +48,22 @@ export class AuthenticationService extends BaseService {
|
|||||||
newUser,
|
newUser,
|
||||||
{ headers: this.headers })
|
{ headers: this.headers })
|
||||||
.pipe(map(user => {
|
.pipe(map(user => {
|
||||||
this.pushUserToken(newUser.login, newUser.password, user);
|
this.pushToken(newUser.login, newUser.password, user);
|
||||||
return 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) {
|
if (user && user.token) {
|
||||||
user.authdata = window.btoa(login + ":" + password);
|
user.authdata = window.btoa(login + ":" + password);
|
||||||
localStorage.setItem("currentUser", JSON.stringify(user));
|
localStorage.setItem("currentUser", JSON.stringify(user));
|
||||||
|
|||||||
Reference in New Issue
Block a user