AspNetRoles ...
This commit is contained in:
parent
27a05bf9c9
commit
4c653f1bf6
16 changed files with 53 additions and 38 deletions
|
|
@ -19,5 +19,10 @@ namespace Yavsc.Server.Helpers
|
|||
return user.Identity.IsAuthenticated;
|
||||
}
|
||||
|
||||
public static bool IsInMsRole(this ClaimsPrincipal user, string roleName)
|
||||
{
|
||||
return user.HasClaim("http://schemas.microsoft.com/ws/2008/06/identity/claims/role", roleName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace Yavsc
|
|||
var userId = _dbContext.Users.First(u => u.UserName == Context.User.Identity.Name).Id;
|
||||
|
||||
await Clients.Group(ChatHubConstants.HubGroupFollowingPrefix + userId).SendAsync("notifyUser", NotificationTypes.Connected, userName, null);
|
||||
isCop = Context.User.IsInRole(Constants.AdminGroupName) ;
|
||||
isCop = Context.User.IsInMsRole(Constants.AdminGroupName) ;
|
||||
if (isCop)
|
||||
{
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, ChatHubConstants.HubGroupCops);
|
||||
|
|
@ -353,7 +353,7 @@ namespace Yavsc
|
|||
var identityUserName = Context.User.GetUserName();
|
||||
|
||||
if (userName[0] != '?' && Context.User!=null)
|
||||
if (!Context.User.IsInRole(Constants.AdminGroupName))
|
||||
if (!Context.User.IsInMsRole(Constants.AdminGroupName))
|
||||
{
|
||||
|
||||
var bl = _dbContext.BlackListed
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue