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