public override bool ValidateUser(string username, string password) { bool isValid = false; using (AccountRepository repository = new AccountRepository()) { try { IUser user = repository.GetUser(username); if (user != null && Crypto.VerifyHashedPassword(user.Password, password)) { isValid = true; } } catch { isValid = false; } } return isValid; }
public override string[] GetRolesForUser(string username) { string[] roles = new string[] { }; using (AccountRepository repository = new AccountRepository()) { try { IUser user = repository.GetUser(username); if (user != null) { roles = repository.GetRolesForUser(username); } } catch { roles = new string[] { }; } } return roles; }
public override MembershipUser GetUser(string username, bool userIsOnline) { try { using(AccountRepository repository = new AccountRepository()) { var user = repository.GetUser(username); if (user != null) { MembershipUser memberUser = new MembershipUser("MyMembershipProvider", user.Nick, null, user.Email, null, null, false, false, user.CreateDateTime, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue); return memberUser; } } } catch { return null; } return null; }
public override bool IsUserInRole(string username, string roleName) { bool result = false; using(AccountRepository repository = new AccountRepository()) { try { IUser user = repository.GetUser(username); if (user != null) { string[] roles = GetRolesForUser(username); result = roles.Contains(roleName); } } catch { result = false; } } return result; }