public override bool ChangePassword(string username, string oldPassword, string newPassword) { if (!ValidateUser(username, oldPassword) || string.IsNullOrEmpty(newPassword.Trim())) { return(false); } user user = repository.GetUser(username); string hash = FormsAuthentication.HashPasswordForStoringInConfigFile(newPassword.Trim(), "md5"); user.Password = hash; int roleMember = repository.GetRole("Member").roleID; int roleRegister = repository.GetRole("Register").roleID; if (user.RoleID == roleRegister) { user.RoleID = roleMember; } repository.Save(); return(true); }
public override bool IsUserInRole(string userName, string roleName) { user user = repository.GetUser(userName); role role = repository.GetRole(roleName); if (!repository.UserExists(user)) { return(false); } if (!repository.RoleExists(role)) { return(false); } if (!(user.RoleID == role.roleID)) { return(false); } return(true); }