public MembershipUser CreateUser(string email, string password) { MembershipUser membershipUser = GetUser(email, false); if (membershipUser == null) { try { using (StudentListContext _db = new StudentListContext()) { User user = new User(); user.Email = email; user.Password = Crypto.HashPassword(password); _db.Users.Add(user); _db.SaveChanges(); membershipUser = GetUser(email, false); return membershipUser; } } catch { return null; } } return null; }
public override bool ValidateUser(string username, string password) { bool isValid = false; using (StudentListContext _db = new StudentListContext()) { try { User user = (from u in _db.Users where u.Email == username select u).FirstOrDefault(); if (user != null && Crypto.VerifyHashedPassword(user.Password, password)) { isValid = true; } } catch { isValid = false; } } return isValid; }