fixed ManageUser allowing to add roles to oneself
This commit is contained in:
parent
c8f0cea89b
commit
8e2589dbc1
|
@ -1,5 +1,4 @@
|
||||||
@page "/manage/users"
|
@page "/manage/users"
|
||||||
@using Microsoft.AspNetCore.Authorization
|
|
||||||
@using Microsoft.AspNetCore.Identity
|
@using Microsoft.AspNetCore.Identity
|
||||||
@using Wave.Data
|
@using Wave.Data
|
||||||
@using Humanizer
|
@using Humanizer
|
||||||
|
@ -93,12 +92,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Add() {
|
private async Task Add() {
|
||||||
|
if (User is null) return;
|
||||||
var user = await UserManager.FindByNameAsync(UserName);
|
var user = await UserManager.FindByNameAsync(UserName);
|
||||||
|
|
||||||
if (user is null) {
|
if (user is null) {
|
||||||
Toast.ShowError(Localizer["Error_UserNotFound"]);
|
Toast.ShowError(Localizer["Error_UserNotFound"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (user.Id == User.Id) {
|
||||||
|
Toast.ShowError(Localizer["Error_EditSelf"]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!await RoleManager.RoleExistsAsync(CurrentRole.ToString())) {
|
if (!await RoleManager.RoleExistsAsync(CurrentRole.ToString())) {
|
||||||
var result = await RoleManager.CreateAsync(new IdentityRole(CurrentRole.ToString()));
|
var result = await RoleManager.CreateAsync(new IdentityRole(CurrentRole.ToString()));
|
||||||
|
|
Loading…
Reference in a new issue