private void register() { if (passwordBox.Password != repPasswordBox.Password) { this.Dispatcher.BeginInvoke(delegate() { MessageBox.Show("Given passwords are different."); }); passwordBox.Password = repPasswordBox.Password = ""; setControlEnabled(true); } else if (loginBox.Text == "" || nameBox.Text == "" || mailBox.Text == "" || passwordBox.Password == "") { this.Dispatcher.BeginInvoke(delegate() { MessageBox.Show("All fields must not be empty."); }); passwordBox.Password = repPasswordBox.Password = ""; setControlEnabled(true); } else { string url = serverUrl + "/api/account/register"; RegistrationInput input = new RegistrationInput(loginBox.Text, nameBox.Text, mailBox.Text, passwordBox.Password); new HttpPostRequest <RegistrationInput, RegistrationOutput>(url, registerCallback, input); } }
public async Task Execute(RegistrationInput input) { //var user = await _userService.FindByName(input.UserName); //if (user != null) //{ // _outputHandler.Error("Unable to create User."); //} var user = new SimpleEntityUser { Email = input.Email, SecurityStamp = Guid.NewGuid().ToString(), UserName = input.UserName }; try { var createdUser = await _userService.Create(user, input.Password); _outputHandler.Handle(createdUser); } catch (Exception ex) { _outputHandler.Error(ex.Message); } }
private LastSupportedVersionKey GetKey(RegistrationInput input, string majorVersion) => new LastSupportedVersionKey { Language = input.Language, Key = input.Key, MajorVersion = majorVersion };
public async Task <IActionResult> Register([FromBody] RegistrationRequest request) { var input = new RegistrationInput(request.UserName, request.Password, request.Email); await _useCase.Execute(input); return(_presenter.ViewModel); }
private void ValidateLastSupportedVersion(RegistrationInput input, string registeredVersion, string versionToTest) { var exceedsLastSupportedVersion = _versionsParser.IsGreaterThan(versionToTest, registeredVersion); if (exceedsLastSupportedVersion) { var message = GetExceptionMessage(input, registeredVersion); throw new InvalidOperationException(message); } }
private string GetExceptionMessage(RegistrationInput input, string lastSupportedVersion) { var builder = new StringBuilder($"The document {input.Key} [{input.Language}] has "); builder.Append($"{nameof(RegistrationInput.LastSupportedVersion)} set to {lastSupportedVersion} "); builder.Append($"but its definition was also included in .docs.json for {input.DocumentationVersion}. "); builder.Append($"Please either remove the {nameof(RegistrationInput.LastSupportedVersion)} field "); builder.Append($"or the .docs.json entry from {input.DocumentationVersion}."); return(builder.ToString()); }
public IActionResult RegisterNewUser(RegistrationInput userInput) { try { User user = new User(userInput); // HACK: this is fixed in another branch, so for now this will HOPEFULLY // keep away any possible collisions. when that happend comment out the next 2 lines. //Random rnd = new Random(); //user.SystemID = rnd.Next(Int32.MinValue, Int32.MaxValue); //HACK: due to time constraints, I realised that gamer tags need to be unique. GamerInfo verifyGamer = _gamerDataAccess.GetGamerInfo(new GamerInfo(null, userInput.GamerTag, 0, 0)); if (verifyGamer == null) { _userManagementManager.SingleCreateUsers(doAsUser.systemAdmin(), user); _userManagementManager.updateGamerTag(user, userInput.GamerTag); } else { user.ErrorMessage = "Gamer tag is already in use"; } ContentResult serverReply = Content(user.ErrorMessage); switch (user.ErrorMessage) { case "Invalid permissions": serverReply.StatusCode = StatusCodes.Status401Unauthorized; break; case "Password is not secured": case "ID already exists": case "Email already registered": case "Email malformed": case "Invalid names": case "Gamer tag is already in use": serverReply.StatusCode = StatusCodes.Status400BadRequest; break; case "Email failed to register": serverReply.StatusCode = StatusCodes.Status500InternalServerError; break; default: serverReply.StatusCode = StatusCodes.Status200OK; break; } return(serverReply); } catch (ArgumentException) { return(StatusCode(StatusCodes.Status400BadRequest)); } }
public void RegisterCompilation(RegistrationInput input) { var majorVersion = _versionsParser.GetMajorVersion(input.DocumentationVersion); var key = GetKey(input, majorVersion); if (_lastSupportedVersions.ContainsKey(key)) { ValidateLastSupportedVersion(input, key); UpdateLastSupportedVersion(input, key); } else { _lastSupportedVersions[key] = input.LastSupportedVersion; } }
private void ValidateLastSupportedVersion(RegistrationInput input, LastSupportedVersionKey key) { var registeredVersion = _lastSupportedVersions[key]; if (string.IsNullOrEmpty(registeredVersion)) { return; } ValidateLastSupportedVersion(input, registeredVersion, input.DocumentationVersion); foreach (var supportedVersion in input.SupportedVersions) { ValidateLastSupportedVersion(input, registeredVersion, supportedVersion); } }
public async Task <RegistrationOutput> Registration(RegistrationInput input) { var user = new User { Login = input.Login, Password = input.Password, Nickname = input.Nickname }; await manager.AddUserAsync(user); var token = await manager.GetTokenForUserAsync(user); return(new RegistrationOutput { Token = token, Nick = user.Nickname }); }
private void UpdateLastSupportedVersion(RegistrationInput input, LastSupportedVersionKey key) { var versionToSet = input.LastSupportedVersion; if (string.IsNullOrEmpty(versionToSet)) { return; } var registeredVersion = _lastSupportedVersions[key]; if (string.IsNullOrEmpty(registeredVersion) == false && _versionsParser.IsGreaterThan(registeredVersion, versionToSet)) { return; } _lastSupportedVersions[key] = versionToSet; }
public async Task RegsiterUseCase_ValidInput_ShouldReturnTheUser() { // Arrange var userService = new FakeUserService(); var presenter = new FakeRegisterOutputHandler(); var sut = new RegisterUseCase(presenter, userService); var input = new RegistrationInput("username", "password", "*****@*****.**"); // Act await sut.Execute(input); // Assert presenter.ErrorMessage .Should() .BeNull(); presenter.ViewModel .Should() .BeEquivalentTo(userService.User); }
public string Registration(RegistrationInput input) { var UserInfo = _regRepository.Users; if (UserInfo.Where(x => x.Username == input.Username).Any()) { return("UserNameFalse"); } else if (UserInfo.Where(x => x.Email == input.Email).Any()) { return("InvalidEmail!"); } else { UsersCore reg = new UsersCore(); reg.Username = input.Username; reg.Email = input.Email; string hashPassword = _passHash.GetPassword(input.Password); reg.Password = hashPassword; _regRepository.Users.Add(reg); _regRepository.SaveChanges(); return("ok"); } }
public JsonResult Registration(RegistrationInput input) { string message = _user.Registration(input); return(Json(message)); }
public string PostAuthenticate(RegistrationInput input) { return("Success"); }
public string PostRegister(RegistrationInput input) { return("Success"); }