Example #1
0
        public async Task <IHttpActionResult> Authorize(UserModel model)
        {
            try
            {
                var authModel = await _authorizationManager.AuthorizeAsync(model.Email, model.Password);

                return(Ok(authModel));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Example #2
0
 public void AuthorizeAsync()
 {
     _authorizationManager.AuthorizeAsync(false, "Permission_Test_1").ShouldNotThrow();
     _authorizationManager.AuthorizeAsync(false).ShouldNotThrow();
     _authorizationManager.AuthorizeAsync(true).ShouldNotThrow();
     _authorizationManager.AuthorizeAsync(false, "Permission_Test_2").ShouldThrow <AuthorizationException>();
     _authorizationManager.AuthorizeAsync(false, "Permission_Test_1", "Permission_Test_2").ShouldNotThrow();
     _authorizationManager.AuthorizeAsync(true, "Permission_Test_1", "Permission_Test_2").ShouldThrow <AuthorizationException>();
 }