#51 adding AdministratorRole to receivers list for notifications
This commit is contained in:
parent
975d03ed3f
commit
6bf6538df7
@ -451,7 +451,7 @@ namespace RMuseum.Services.Implementationa
|
||||
(
|
||||
(Guid)moderator.Id ,
|
||||
"درخواست بررسی خوانش",
|
||||
$"درخواستی برای بررسی خوانشی از «{narration.AudioArtist}» ثبت شده است. در صورت تمایل صورت تمایل به بررسی بخش «خوانشهای در انتظار تأیید» را ببینید.{ Environment.NewLine}" +
|
||||
$"درخواستی برای بررسی خوانشی از «{narration.AudioArtist}» ثبت شده است. در صورت تمایل به بررسی، بخش «خوانشهای در انتظار تأیید» را ببینید.{ Environment.NewLine}" +
|
||||
$"توجه فرمایید که اگر کاربر دیگری که دارای مجوز بررسی خوانشهاست پیش از شما به آن رسیدگی کرده باشد آن را در صف نخواهید دید."
|
||||
);
|
||||
}
|
||||
|
||||
@ -2055,11 +2055,6 @@
|
||||
<param name="email"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:RSecurityBackend.Services.IAppUserService.AdministratorRoleName">
|
||||
<summary>
|
||||
Administrator role name
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RSecurityBackend.Services.IAppUserService.TokenSecret">
|
||||
<summary>
|
||||
secret used for generating Jwt token
|
||||
@ -2394,11 +2389,6 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:RSecurityBackend.Services.Implementation.AppUserService.AdministratorRoleName">
|
||||
<summary>
|
||||
Administrator role name
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RSecurityBackend.Services.Implementation.AppUserService.TokenSecret">
|
||||
<summary>
|
||||
secret used for generating Jwt token
|
||||
@ -2767,6 +2757,11 @@
|
||||
User Roles Service Implementation
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RSecurityBackend.Services.Implementation.RoleServiceBase.AdministratorRoleName">
|
||||
<summary>
|
||||
Administrator role name
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:RSecurityBackend.Services.Implementation.RoleServiceBase.GetAllRoles">
|
||||
<summary>
|
||||
returns all user roles
|
||||
@ -2919,6 +2914,11 @@
|
||||
User Groups Service
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RSecurityBackend.Services.IUserRoleService.AdministratorRoleName">
|
||||
<summary>
|
||||
Administrator role name
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:RSecurityBackend.Services.IUserRoleService.GetAllRoles">
|
||||
<summary>
|
||||
returns all user roles
|
||||
|
||||
@ -255,10 +255,7 @@ namespace RSecurityBackend.Services
|
||||
Task<RServiceResult<PublicRAppUser>> FindUserByEmail(string email);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Administrator role name
|
||||
/// </summary>
|
||||
string AdministratorRoleName { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// secret used for generating Jwt token
|
||||
|
||||
@ -11,6 +11,11 @@ namespace RSecurityBackend.Services
|
||||
/// </summary>
|
||||
public interface IUserRoleService
|
||||
{
|
||||
/// <summary>
|
||||
/// Administrator role name
|
||||
/// </summary>
|
||||
string AdministratorRoleName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// returns all user roles
|
||||
/// </summary>
|
||||
|
||||
@ -387,7 +387,7 @@ namespace RSecurityBackend.Services.Implementation
|
||||
return new RServiceResult<bool>(false, "کاربر مورد نظر یافت نشد");
|
||||
}
|
||||
|
||||
bool res = await _userManager.IsInRoleAsync(dbUserInfo, AdministratorRoleName);
|
||||
bool res = await _userManager.IsInRoleAsync(dbUserInfo, _userRoleService.AdministratorRoleName);
|
||||
return new RServiceResult<bool>(res);
|
||||
}
|
||||
catch(Exception exp)
|
||||
@ -689,9 +689,9 @@ namespace RSecurityBackend.Services.Implementation
|
||||
if(newUserInfo.IsAdmin)
|
||||
{
|
||||
|
||||
if (!await _roleManager.RoleExistsAsync(AdministratorRoleName))
|
||||
if (!await _roleManager.RoleExistsAsync(_userRoleService.AdministratorRoleName))
|
||||
{
|
||||
var roleCheckResult = await _roleManager.CreateAsync(new RAppRole(AdministratorRoleName));
|
||||
var roleCheckResult = await _roleManager.CreateAsync(new RAppRole(_userRoleService.AdministratorRoleName));
|
||||
if (!roleCheckResult.Succeeded)
|
||||
{
|
||||
return new RServiceResult<RAppUser>(null, "Error creating Administrator role : " + ErrorsToString(roleCheckResult.Errors));
|
||||
@ -699,7 +699,7 @@ namespace RSecurityBackend.Services.Implementation
|
||||
}
|
||||
|
||||
|
||||
var addToAdminRoleResult = await _userManager.AddToRoleAsync(newDbUser, AdministratorRoleName);
|
||||
var addToAdminRoleResult = await _userManager.AddToRoleAsync(newDbUser, _userRoleService.AdministratorRoleName);
|
||||
if (!addToAdminRoleResult.Succeeded)
|
||||
{
|
||||
return new RServiceResult<RAppUser>(null, $"Error adding {newDbUser.UserName} to Administrator role : " + ErrorsToString(addToAdminRoleResult.Errors));
|
||||
@ -740,7 +740,7 @@ namespace RSecurityBackend.Services.Implementation
|
||||
|
||||
if(isAdmin.Result && !updateUserInfo.IsAdmin)
|
||||
{
|
||||
List<RAppUser> adminUsers = new List<RAppUser>(await _userManager.GetUsersInRoleAsync(AdministratorRoleName));
|
||||
List<RAppUser> adminUsers = new List<RAppUser>(await _userManager.GetUsersInRoleAsync(_userRoleService.AdministratorRoleName));
|
||||
int nActiveAdminUsers = 0;
|
||||
foreach(RAppUser adminUser in adminUsers)
|
||||
{
|
||||
@ -1355,16 +1355,16 @@ namespace RSecurityBackend.Services.Implementation
|
||||
return new RServiceResult<bool>(false, "Error creating default user : " + ErrorsToString(identityResult.Errors));
|
||||
}
|
||||
|
||||
if (!await _roleManager.RoleExistsAsync(AdministratorRoleName))
|
||||
if (!await _roleManager.RoleExistsAsync(_userRoleService.AdministratorRoleName))
|
||||
{
|
||||
identityResult = await _roleManager.CreateAsync(new RAppRole(AdministratorRoleName));
|
||||
identityResult = await _roleManager.CreateAsync(new RAppRole(_userRoleService.AdministratorRoleName));
|
||||
if (!identityResult.Succeeded)
|
||||
{
|
||||
return new RServiceResult<bool>(false, "Error creating Administrator role : " + ErrorsToString(identityResult.Errors));
|
||||
}
|
||||
}
|
||||
|
||||
identityResult = await _userManager.AddToRoleAsync(admin, AdministratorRoleName);
|
||||
identityResult = await _userManager.AddToRoleAsync(admin, _userRoleService.AdministratorRoleName);
|
||||
if (!identityResult.Succeeded)
|
||||
{
|
||||
return new RServiceResult<bool>(false, "Error adding admin to Administrator role : " + ErrorsToString(identityResult.Errors));
|
||||
@ -1379,10 +1379,7 @@ namespace RSecurityBackend.Services.Implementation
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Administrator role name
|
||||
/// </summary>
|
||||
public string AdministratorRoleName { get { return "Administrator"; } }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -16,6 +16,11 @@ namespace RSecurityBackend.Services.Implementation
|
||||
/// </summary>
|
||||
public class RoleServiceBase : IUserRoleService
|
||||
{
|
||||
/// <summary>
|
||||
/// Administrator role name
|
||||
/// </summary>
|
||||
public string AdministratorRoleName { get { return "Administrator"; } }
|
||||
|
||||
/// <summary>
|
||||
/// returns all user roles
|
||||
/// </summary>
|
||||
@ -197,7 +202,7 @@ namespace RSecurityBackend.Services.Implementation
|
||||
{
|
||||
RAppRole[] rolesInfo = await _roleManager.Roles
|
||||
.Include(r => r.Permissions)
|
||||
.Where(r => r.Permissions.Any(p => p.SecurableItemShortName == securableItemShortName && p.OperationShortName == operationShortName) )
|
||||
.Where(r => r.Name == AdministratorRoleName || r.Permissions.Any(p => p.SecurableItemShortName == securableItemShortName && p.OperationShortName == operationShortName) )
|
||||
.ToArrayAsync();
|
||||
return new RServiceResult<RAppRole[]>(rolesInfo);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user