Created
July 23, 2019 09:52
-
-
Save ntakouris/9f34227d5dcb7072d501984e4687b38e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WorksForCompanyHandler : AuthorizationHandler<WorksForCompanyRequirement> | |
{ | |
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, WorksForCompanyRequirement requirement) | |
{ | |
var userEmailAddress = context.User?.FindFirstValue(ClaimTypes.Email) ?? string.Empty; | |
if (userEmailAddress.EndsWith(requirement.DomainName)) | |
{ | |
context.Succeed(requirement); | |
return Task.CompletedTask; | |
} | |
context.Fail(); | |
return Task.CompletedTask; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment