public bool ChangePassword(Guid userId, string password) { BL.User user = db.Users.Where(u => u.UserID == userId).FirstOrDefault(); if (user != null) { BL.Helpers.MD5CryptoServiceProvider md5 = new BL.Helpers.MD5CryptoServiceProvider(); if (md5.getMd5Hash(password) != user.Password) { using (var ts = new TransactionScope()) { user.Password = md5.getMd5Hash(password); db.SubmitChanges(); ts.Complete(); } return true; } } return false; }
public bool SetNewPasswordByUserId(Guid userId, string password) { BL.User user = GetUserById(userId); if (user != null) { if (user.IsActive) { BL.Helpers.MD5CryptoServiceProvider md5 = new BL.Helpers.MD5CryptoServiceProvider(); using (var ts = new TransactionScope()) { user.Password = md5.getMd5Hash(password); user.ConfirmationID = null; db.SubmitChanges(); ts.Complete(); } return true; } } return false; }
/// <summary> /// Registration User, Send Mail With ConfirmI /// </summary> /// <param name="login"></param> /// <param name="email"></param> /// <param name="password"></param> /// <param name="usersProperties"></param> public void RegisterUser(string login, string email, string password) { BL.User user = new BL.User(); BL.Helpers.MD5CryptoServiceProvider md5 = new BL.Helpers.MD5CryptoServiceProvider(); BL.Modules.Users.UserRoles userRoles = new BL.Modules.Users.UserRoles(); BL.Modules.Users.UserRights userRights = new BL.Modules.Users.UserRights(); Guid ConfirmationId = Guid.NewGuid(); using (var ts = new TransactionScope()) { user.UserID = Guid.NewGuid(); user.Login = login; user.Email = email; user.Password = md5.getMd5Hash(password); user.IsActive = false; user.ConfirmationID = ConfirmationId; user.UserRoleID = userRoles.User; user.UserRightID = userRights.Read; db.Users.InsertOnSubmit(user); db.SubmitChanges(); ts.Complete(); } BL.Modules.Mail.Mail.Registration(user); }