string[] credentials = Encoding.ASCII.GetString(Convert.FromBase64String(authValue.Parameter)).Split(new[] { ':' }); if (credentials.Length != 2 || string.IsNullOrEmpty(credentials[0]) || string.IsNullOrEmpty(credentials[1])) { //return Unauthorized(request); var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(string.Format("access denied")), }; } ClaimRole user = repository.trial(credentials[0], credentials[1]); ClaimRole user2 = repository.unlim(credentials[0], credentials[1]); if (user == null || user2 == null ) { var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(string.Format("access denied")), }; } else { IPrincipal principal = new GenericPrincipal(new GenericIdentity(user.Username, BasicAuthResponseHeaderValue), new string[] { user.role }); //IPrincipal principal = new GenericPrincipal(new GenericIdentity(user.Username, BasicAuthResponseHeaderValue), null); Thread.CurrentPrincipal = principal; HttpContext.Current.User = principal; } return base.SendAsync(request, cancellationToken); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)