bill
This commit is contained in:
parent
08606c106b
commit
a120dae977
144 changed files with 10574 additions and 1527 deletions
27
Yavsc/AuthorizationHandlers/HasTemporaryPassHandler.cs
Normal file
27
Yavsc/AuthorizationHandlers/HasTemporaryPassHandler.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth.Handlers
|
||||
{
|
||||
public class HasTemporaryPassHandler : AuthorizationHandler<PrivateChatEntryRequirement>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, PrivateChatEntryRequirement requirement)
|
||||
{
|
||||
if (!context.User.HasClaim(c => c.Type == "TemporaryBadgeExpiry" &&
|
||||
c.Issuer == Startup.Authority))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var temporaryBadgeExpiry =
|
||||
Convert.ToDateTime(context.User.FindFirst(
|
||||
c => c.Type == "TemporaryBadgeExpiry" &&
|
||||
c.Issuer == Startup.Authority).Value);
|
||||
|
||||
if (temporaryBadgeExpiry > DateTime.Now)
|
||||
{
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue