public async Task <Response <bool> > Register(User user) { Response <bool> response = new Response <bool>(); // Check if user with this email already exists var existingUser = await _userRepository.GetUserByEmail(user.Email); if (existingUser != null) { return(response.Failed("User already exists.", false)); } // Populate other properties user.SignUpDate = DateTime.Now; user.Password = PasswordCrypter.CryptPassword(user.Password); try { await _userRepository.SaveUser(user); return(response.Success("User successfully created.", true)); } catch (Exception) { return(response.Failed("Could not create user.", false)); } }
public async Task <ActionResult> Register(UserAccount account) { // ovde provere... string hashed = pcrypter.CryptPassword(account.Password); await mongoDatabase.UserCollection.InsertOneAsync(new UserAccount { Email = account.Email, Username = account.Username, FullName = account.FullName, Password = hashed }); return(RedirectToAction("Login")); }
public static ActualResult Register(Client client) { client.Password = PasswordCrypter.CryptPassword(client.Password); return(ClientRepository.InsertClient(client)); }