public override string[] GetRolesForUser(string username) { if (!HttpContext.Current.User.Identity.IsAuthenticated) { return(null); } var cacheKey = string.Format("{0}_role", username); if (HttpRuntime.Cache[cacheKey] != null) { return((string[])HttpRuntime.Cache[cacheKey]); } string[] roles = new string[] { }; using (DB_A28A4D_setzEntities db = new DB_A28A4D_setzEntities()) { roles = (from c in db.Users where c.PhoneNumber.Equals(username) select c.Role).ToArray <string>(); if (roles.Count() > 0) { HttpRuntime.Cache.Insert(cacheKey, roles, null, DateTime.Now.AddMinutes(_cashTimeoutInMinute), Cache.NoSlidingExpiration); } } return(roles); }
public override bool ValidateUser(string username, string password) { using (DB_A28A4D_setzEntities db = new DB_A28A4D_setzEntities()) { var user = db.Users.Where(a => a.PhoneNumber.Equals(username) && a.Password.Equals(password)).FirstOrDefault(); if (user != null) { return(true); } } return(false); }