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); }
/// <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)); }