예제 #1
0
        protected override bool IsAuthorized(HttpActionContext actionContext)
        {
            var identity = Thread.CurrentPrincipal.Identity;

            if (identity != null && identity.IsAuthenticated)
            {
                userGetService = new UserGetService(); //IOC

                var basicAuth = identity as BasicAuthenticationIdentity;

                User user = userGetService.Get(basicAuth.Name, basicAuth.Password);

                if (user != null)
                {
                    basicAuth.User = user;
                    SetPrincipal(Thread.CurrentPrincipal);
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
 /// <summary>
 /// Get User.
 /// </summary>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public User Get(string userName, string password)
 {
     return(getService.Get(userName, password));
 }