Dear all,
I would like to know, how to I go about passing parameters (username and password) into the following method, using a bool type method such as the one in user class.
public class BasicAuthHandler : DelegatingHandler { private const string BasicAuthResponseHeader = "WWW-Authenticate"; private const string BasicAuthResponseHeaderValue = "Basic"; //private readonly iUser repository; public BasicAuthHandler(iUser repository) { this.repository = repository; } [Inject] iUser repository { get; set; } private ParseAuthorizationHeader(string authHeader) { string[] credentials = Encoding.ASCII.GetString(Convert.FromBase64String(authHeader)).Split(new[] { ':' }); if (credentials.Length != 2 || string.IsNullOrEmpty(credentials[0]) || string.IsNullOrEmpty(credentials[1])) return null; return new () { username = credentials[0], password = credentials[1], }; }
User class:
public class User : iUser { private cdwEntities db; public User() { db = new cdwEntities(); } public User(cdwEntities context) { db = context; } public bool subs(string username, string password) { //define the query : query will be an IQueryable var query = from s in db.Subscriptions join u in db.UserDetails on s.sUID equals u.uID where s.sExpiryDate >= DateTime.Now && s.sPID.Value == 163 && u.uUsername == username && u.uPassword == password select u; // // "execute" the query return query.FirstOrDefault() != null; // if there is a result it will return true }
Please help. Many thanks in advance.