public async Task <object> DoRegister([FromServices] IHttpContextAccessor accessor, Models.Account account) { //await Task.Delay(1); if (ModelState.IsValid == false) { return(new { success = ModelState.IsValid, errors = GetModelErrors() }); } var accountExists = _registerService.AccountExists(account.Name); if (accountExists) { ModelState.AddModelError("Username", "Pick another username!"); return(new { success = false, errors = GetModelErrors() }); } account.IP = accessor.HttpContext.Connection.RemoteIpAddress.ToString(); await _registerService.SaveAccount(account); return(new { success = true }); }
private void RegisterBtnClick(object sender, RoutedEventArgs e) { string username = UsernameBox.Text; if (username.Length <= 2) { errorText.Text = "Username is too short"; return; } service.AccountExists(username, out bool exists, out bool exists2); if (exists) { errorText.Text = "Username is invalid"; return; } service.Register(username, password.Text); errorText.Text = "User created!"; }