public HttpResponse Register(InputUserRegistrationModel input) { if (string.IsNullOrWhiteSpace(input.Email)) { return(this.Redirect("/Users/Register")); } if (input.Password.Length < DataConstants.UserPasswordMinLength || input.Password.Length > DataConstants.UserPasswordMaxLength) { return(this.Redirect("/Users/Register")); } if (input.Username.Length < DataConstants.UsernameMinLenght || input.Username.Length > DataConstants.UsernameMaxLenght) { return(this.Redirect("/Users/Register")); } if (input.Password != input.ConfirmPassword) { return(this.Redirect("/Users/Register")); } if (this.usersService.EmailExists(input.Email)) { return(this.Redirect("/Users/Register")); } if (this.usersService.UsernameExists(input.Username)) { return(this.Redirect("/Users/Register")); } this.usersService.Register(input.Username, input.Email, input.Password); return(this.Redirect("/Users/Login")); }
public bool ValidateUser(InputUserRegistrationModel model, IUsersService usersService) { if (model.Username.Length < 5 || model.Username.Length > 20) { return(false); } if (String.IsNullOrEmpty(model.Email)) { return(false); } if (model.Password.Length < 6 || model.Password.Length > 20) { return(false); } if (model.Password != model.ConfirmPassword) { return(false); } return(true); }