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); }
//internal IUserGetService getService; public UserService() { getService = new UserGetService(); saveService = new UserSaveService(); deleteService = new UserDeleteService(); }