public void ResetPassword(string hash, string newPassword) { //caso já tiver solicitado o password não gera novamente var userPasswordRecovery = GetUserPasswordRecoveryByHash(hash); if (userPasswordRecovery == null) { throw new Exception("Not Hash"); } var userBD = _userAppService.GetUserByEmail(userPasswordRecovery.Email); if (userBD == null) { throw new Exception("User not find"); } DateTime dateHour = DateHour.GetDateTimeServer(); Update(new UserPasswordRecovery { UpdateDate = dateHour, Hash = hash }); userBD.Password = Encryptor.GenerateHashMd5(newPassword); userBD.UpdateDate = dateHour; _userAppService.Update(userBD); }
public void AddUserRegister(User user, Profile profile, List <UserNotes> userNotes) { //verificar se já existe o usuário var userBD = _userAppService.GetUserByEmail(user.Email); if (userBD != null) { throw new Exception("Usuário existente."); } user.Password = Encryptor.GenerateHashMd5(user.Password); user.CreateDate = DateHour.GetDateTimeServer(); _userAppService.Insert(user); profile.IdUser = user.IdUser; _profileAppService.Insert(profile); userNotes.All(c => { c.IdUser = user.IdUser; return(true); }); userNotes.All(c => { c.Note = Encryptor.Encrypt(c.Note); return(true); }); foreach (var note in userNotes) { _userNoteAppService.Insert(note); } }
public string UserGenerateHash(string email) { //caso já tiver solicitado o password não gera novamente var userPasswordRecovery = GetUserPasswordRecoveryByEmail(email); if (userPasswordRecovery != null) { return(userPasswordRecovery.Hash); } string hash = Guid.NewGuid().ToString().Replace("-", ""); Insert(new UserPasswordRecovery { Email = email, CreateDate = DateHour.GetDateTimeServer(), Hash = hash }); return(hash); }