public bool ResetPassword(string login, string document, string newPassword) { try { Users userModel = repository.filter(u => u.login.Equals(login) && u.document.Equals(document) && u.active).SingleOrDefault(); UserEntity user = convertModelToEntity(userModel); if (user != null) { var keyNew = CryptographySHA1.GeneratePassword(10); var password = CryptographySHA1.EncodePassword(newPassword, keyNew); user.password = password; user.verificationCode = keyNew; base.update(ref user); sendEmailUser(user, newPassword); return(true); } throw new ArgumentException("Login or Document are Incorrent!"); } catch (Exception ex) { throw ex; } }
public override void add(ref UserEntity entity, bool persistir = true) { try { string randomPassword = Membership.GeneratePassword(6, 1); var keyNew = CryptographySHA1.GeneratePassword(10); var password = CryptographySHA1.EncodePassword(randomPassword, keyNew); entity.password = password; entity.verificationCode = keyNew; entity.active = true; base.add(ref entity, persistir); sendEmailUser(entity, randomPassword); } catch (Exception ex) { throw ex; } }