public RequestRegister RequestRegister(string fname, string lname, string email, string password, string name) { RequestRegister request = new RequestRegister(); request.Send(fname, lname, email, password, name); return request; }
public ActionResult <ResponseRegister> Register(RequestRegister requestRegister) { var responseRegister = new ResponseRegister(); using (var db = new NetCoreAuthJwtMySqlContext()) { if (!db.User.Any(x => x.Email == requestRegister.Email)) { var email = requestRegister.Email; var salt = CryptoUtil.GenerateSalt(); var password = requestRegister.Password; var hashedPassword = CryptoUtil.HashMultiple(password, salt); var user = new User(); user.Email = email; user.Salt = salt; user.Password = hashedPassword; user.Role = "USER"; db.User.Add(user); db.SaveChanges(); responseRegister.Success = true; } else { responseRegister.MessageList.Add("Email is already in use"); } } return(responseRegister); }
public ResponseResult <bool> Register(RequestRegister request, string hostAddress) { Console.WriteLine("Entered Register with Params"); Console.WriteLine(request.userId); Console.WriteLine(request.protocol); Console.WriteLine(hostAddress); Console.WriteLine("End Register"); var userRegistered = DynamoDbClientWithCache.Instance.Get <short, User>(request.userId); if (userRegistered == null) { throw new UnauthorizedUserException(RegisterExceptionMessage.ForUnauthorized("ID Not Issued")); } if (userRegistered.accesskey != request.AccessKey) { throw new UnauthorizedAccessException(RegisterExceptionMessage.ForUnauthorized("Access Key Incorrect")); } var user = new User() { id = request.userId, server_host = hostAddress, protocol = request.protocol }; DynamoDbClientWithCache.Instance.Set <short, User>(user.id, user); return(new ResponseResult <bool>(true)); }
public void Register(string username, string email, string password) { RequestRegister request = new RequestRegister(); request.send(username, email, password); cManager.send(request); }
public void OnClickBtnRegister() { if (IsBusy) { return; } IsBusy = true; var data = new RequestRegister(); data.Account = Account.text; data.Password = Password.text; data.Name = Name.text; NetworkManager.Instance.Post <ResponseRegister, ResponeError>("/api/register", data, null, (resp) => { Datacenter.Instance.AccessToken = resp.AccessToken; Datacenter.Instance.UserName = resp.User.Name; Datacenter.Instance.Money = resp.User.Money; ProdctPage.SetActive(true); gameObject.SetActive(false); IsBusy = false; }, (resp) => { ErrorText.text = resp.Error; ErrorPanel.SetActive(true); IsBusy = false; }); }
private void confirmLoginRegisterButton_Click(object sender, EventArgs e) { if (mode == Mode.LOGIN) { RequestLogIn?.Invoke(usernameExtendedTextBox.GetText(), passwordExtendedTextBox.GetText()); usernameExtendedTextBox.SetEmpty(); passwordExtendedTextBox.SetEmpty(); } else if (mode == Mode.REGISTER && usernameExtendedTextBox.ValidateAndGetResult() && passwordExtendedTextBox.ValidateAndGetResult() && firstNameExtendedTextBox.ValidateAndGetResult() && lastNameExtendedTextBox.ValidateAndGetResult() && emailExtendedTextBox.ValidateAndGetResult()) { RegisterRequest request = new RegisterRequest { Username = usernameExtendedTextBox.GetText(), Password = passwordExtendedTextBox.GetText(), FirstName = firstNameExtendedTextBox.GetText(), LastName = lastNameExtendedTextBox.GetText(), Email = emailExtendedTextBox.GetText() }; RequestRegister?.Invoke(request); usernameExtendedTextBox.SetEmpty(); passwordExtendedTextBox.SetEmpty(); firstNameExtendedTextBox.SetEmpty(); lastNameExtendedTextBox.SetEmpty(); emailExtendedTextBox.SetEmpty(); } else { MessageBox.Show("Wpisano niepoprawne dane", "Błąd", MessageBoxButtons.OK); } }
public RequestRegister requestRegister(string username, string password) { RequestRegister request = new RequestRegister(); request.send(username, password); return(request); }
public RequestRegister RequestRegister(string fname, string lname, string email, string password, string name) { RequestRegister request = new RequestRegister(); request.Send(fname, lname, email, password, name); return(request); }
private void InitializeLoginForm() { loginForm = LoginForm.GetInstance(); loginForm.RequestRegister += (RegisterRequest request) => RequestRegister?.Invoke(request); loginForm.RequestLogIn += (string login, string password) => RequestLogIn?.Invoke(login, password); loginForm.FormClosing += (object sender, FormClosingEventArgs e) => activeForm = null; }
public void Register() { username = usernameText.text; password = passwordText.text; email = emailText.text; RequestRegister request = new RequestRegister(); request.send(username, email, password); cManager.send(request); }
private void HandleUserRegistration(NetworkPacket netPacket, string defaultChat = "allchat") { RequestRegister requestRegister = RequestRegister.StaticDeserialize(netPacket.Message.ToArray()); HandleUserRegistrationResult( netPacket, defaultChat, requestRegister, databaseManager.Register(requestRegister.Username, requestRegister.Password)); }
public bool SendRegisterRequest(string userID, string password) { if (cManager && cManager.IsConnected()) { RequestRegister request = new RequestRegister(); request.send(userID, password); cManager.send(request); return(true); } return(false); }
public async Task <ApiResult> Register(RequestRegister model) { var result = await _userService.CreateAsync(model.UserName, model.Password); if (result.Succeeded) { return(ApiResult.Ok()); } return(ApiResult.Err("注册失败")); }
//请求注册 public static void RequestRegister(string account, string username, string password) { RequestRegister req = new RequestRegister() { Proto = (int)CmdEnum.ReqRegister, Account = account, Username = username, Password = password }; byte[] data = ProtobufTool.CreateData(req.Proto, req); Request((CmdEnum)req.Proto, data); }
public async Task Register() { RequestRegister requestRegister = new RequestRegister() { email = Guid.NewGuid().ToString() + "@hotmail.com", password = Guid.NewGuid().ToString(), github_username = "******" }; var request = ConvertStringContent(requestRegister); var response = await client.PostAsync("/api/user/register", request); ThrowNewException(response); }
public async Task <ApiResult> Register(RequestRegister model) { var user = new ApplicationUser { Name = model.UserName }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { return(ApiResult.Ok()); } return(ApiResult.Err("注册失败")); }
static void Main() { RequestRegister registerRequest = new RequestRegister(); registerRequest.email = "*****@*****.**"; registerRequest.name = "Nuno Neto"; registerRequest.department = "1"; registerRequest.password = "******"; registerRequest.confirmPassword = "******"; ResponseRegister response = (ResponseRegister)makeRequest <ResponseRegister>("/auth/register", registerRequest); Console.WriteLine(response.error + " " + response.message + " " + response.insertedId); }
private async void Complete() { ValidatePasswords(); if (string.IsNullOrEmpty(ErrorPassword) && string.IsNullOrEmpty(ErrorConfirmationPassword)) { dialogService.ShowProgress(); Register register = new Register(); ViewModelHelper.SetRegisterViemModelToRegister(this, register); RequestRegister request = new RequestRegister { Register = register }; ResponsePreRegister response = await apiService.Register(request); dialogService.HideProgress(); ValidateRegister(response); } }
public IActionResult Register([FromBody] RequestRegister registerItem) { BaseResult <long> baseResult = new BaseResult <long>(); if (!Validate <RequestRegisterValidaitor>(registerItem)) { baseResult.statusCode = HttpStatusCode.NotFound; baseResult.message = _SMethod.Get_Enum_Description(enumErrorMessage.invalidModel); return(new NotFoundObjectResult(baseResult)); } bool checkGithubUser = _SGithub.Check_Github_User(registerItem.github_username).Item1; if (!checkGithubUser) { baseResult.statusCode = HttpStatusCode.NotFound; baseResult.message = _SMethod.Get_Enum_Description(enumErrorMessage.githubUserNotFound); return(new NotFoundObjectResult(baseResult)); } User user = _SUser.Check_User(registerItem.email, registerItem.github_username); if (user != null) { baseResult.statusCode = HttpStatusCode.NotFound; baseResult.message = _SMethod.Get_Enum_Description(enumErrorMessage.duplicatedUser); return(new NotFoundObjectResult(baseResult)); } baseResult.data = _SUser.Insert_User(new User { github_username = registerItem.github_username, email = registerItem.email, password = _SMethod.Generate_MD5(registerItem.password), default_lang = "en", creation_date = DateTime.Now, creator_id = 0, status_id = (int)enumStatus.Aktif }); if (baseResult.data < 1) { baseResult.statusCode = HttpStatusCode.NotFound; baseResult.message = _SMethod.Get_Enum_Description(enumErrorMessage.unSuccessful); return(new NotFoundObjectResult(baseResult)); } return(new JsonResult(baseResult)); }
public IHttpActionResult Register([FromBody] RequestRegister request) { var userBll = new UserManage(); var user = new User() { IsValid = true, HeadImgUrl = request.HeadImgUrl, Pwd = request.Pwd, UserName = request.UserName, Email = request.Email }; bool isSuccess = userBll.Save(user); return(Json(new ResponseMsg() { IsSuccess = isSuccess })); }
private void submitButton_Click(object sender, EventArgs e) { RequestRegister request = new RequestRegister(); request.email = emailBox.Text; request.name = usernameBox.Text; request.department = (departmentComboBox.SelectedIndex + 1).ToString(); request.password = passwordBox.Text; request.confirmPassword = password2Box.Text; //Making the register request ResponseRegister response = (ResponseRegister)WebRequestPost.makeRequest <ResponseRegister>("/auth/register", request); if (response.error.Equals("0")) { MessageBox.Show( "User registered with id: " + response.insertedId, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (response.error.Equals("1")) { MessageBox.Show( response.message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show( "What??", "Seriously, what?", MessageBoxButtons.OK, MessageBoxIcon.Question); } this.Hide(); }
private void RegisterClicked(object sender, RoutedEventArgs e) { RequestRegister?.Invoke(this.usernameBox.Text, this.passwordBox.Password, this.passwordConfirmationBox.Password, this.emailBox.Text); }
public async Task <ApiResult <string> > Register(RequestRegister model, [FromQuery] string culture) { string[] names; object[] values; switch (model.Type) { case 1: case 2: if (!CheckVerCode(model.InternationalAreaCode + model.Mobile, model.VerCode, 0)) { throw ApiException.Common(RequestLocalizer["The verification code is incorrect or expired"]); } names = new[] { nameof(IUser.Name), nameof(IUser.DisplayName), nameof(IUser.Mobile), nameof(IUser.Password), }; // 模式2,不带密码,默认密码由内部生成,应用应该引导用户修改密码后使用 values = new object[] { model.Mobile, model.Mobile, model.Mobile, model.Password }; break; case 3: case 4: if (!CheckVerCode(model.Mail, model.VerCode, 1)) { throw ApiException.Common(RequestLocalizer["The verification code is incorrect or expired"]); } names = new[] { nameof(IUser.Name), nameof(IUser.DisplayName), nameof(IUser.Mail), nameof(IUser.Password), }; values = new object[] { model.Mail, model.Mail, model.Mail, model.Password }; break; case 0: default: names = new[] { nameof(IUser.Name), nameof(IUser.DisplayName), nameof(IUser.Password), }; values = new object[] { model.UserName, model.UserName, model.Password }; break; } var result = await _userService.CreateAsync(names, values); if (result.Succeeded) { return(ApiResult.Ok()); } var err = result.Errors.ToArray()[0]; XTrace.WriteLine($"创建用户发生错误:{err.Description}"); throw ApiException.Common(RequestLocalizer[err.Code]); }
public async Task <JsonResult> OnPost([FromBody] RequestRegister registro) { var token = HttpContext.Session.GetString("token"); Country = User.Claims.Where(x => x.Type == "Country").Select(x => x.Value).SingleOrDefault(); var respuesta = await new CaptchaValidation().Validate(registro.TokenReCaptcha); if (!respuesta.Success || respuesta.Score < 0.5) { return(new JsonResult("errorCaptcha")); } string ID = null; var registroGuardar = registro.Person; registroGuardar.Document.Id = null; if (registroGuardar.Email != null) { registroGuardar.Email.Id = null; } if (registroGuardar.Address != null) { registroGuardar.Address.Id = null; } if (registroGuardar.Phone != null) { registroGuardar.Phone.Id = null; } if (registroGuardar.Contacts != null) { foreach (var contacto in registroGuardar.Contacts) { contacto.Id = null; } } if (HttpContext.Session.GetString("registroDesemascarado") != null && HttpContext.Session.GetString("registroDesemascarado") != "null" && HttpContext.Session.GetString("registroDesemascarado") != "") { var people = JsonConvert.DeserializeObject <Prospecto>(HttpContext.Session.GetString("People")); var data = JsonConvert.DeserializeObject <Persons>(HttpContext.Session.GetString("registroDesemascarado")); string participante = null; if (people != null) { ID = people.Id; if (people.Agreements != null) { foreach (var iden in people.Agreements) { if (registroGuardar.Participant == "BACKOFFICE" && iden.Participant == "CONFIRMANT") { participante = "bank"; } } } } if (participante == null) { data.Participant = registroGuardar.Participant; if (registroGuardar.Discriminator == "LEGAL") { data.Email = null; } if (registroGuardar.Accepted_agreement == true) { data.Accepted_agreement = true; } else { data.Accepted_agreement = false; } if (registroGuardar.Participant == "BACKOFFICE") { data.Routing_number = registroGuardar.Routing_number; data.Related = registroGuardar.Related; foreach (var contacto in registroGuardar.Contacts) { if (contacto.Label == "ADMINISTRATOR") { data.Contacts.Add(contacto); } } } data.Accounts = new List <TuFactoringModels.nuevaVersion.Account>(); data.Suppliers = new List <Associate>(); data.Customers = new List <Associate>(); registroGuardar = data; } } registroGuardar.Country = int.Parse(Request.Cookies["Country"]); int?id = 0; if (registroGuardar.Participant != "BACKOFFICE" && registroGuardar.Participant != "CONFIRMANT") { id = HttpContext.Session.GetInt32("idRegistro"); } registrarClienteTF.DataPaises = JsonConvert.DeserializeObject <ListCountry>(HttpContext.Session.GetString("CountryRegister")); if (registroGuardar.Accounts != null) { if (registrarClienteTF.DataPaises != null) { if (registrarClienteTF.DataPaises.Currencies != null) { foreach (var moneda in registrarClienteTF.DataPaises.Currencies) { int principal = 0; if (registroGuardar.Accounts.Count > 0) { foreach (var cuenta in registroGuardar.Accounts) { if (moneda.Id == cuenta.Currency && principal == 0) { principal = 1; cuenta.Default = true; } cuenta.Status = true; } } } } } } if (registroGuardar.Address != null) { registroGuardar.Address.Label = "LEGAL"; } RegistroValidation validator = new RegistroValidation("nada"); var result = validator.Validate(registroGuardar); if (result.IsValid) { Prospecto actualizado = new Prospecto(); registroGuardar.Address.Country = int.Parse(Request.Cookies["Country"]); if (registroGuardar.Phone != null) { registroGuardar.Phone.Country = int.Parse(Request.Cookies["Country"]); } string registrado = null; if (id == 1 || registroGuardar.Participant == "CONFIRMANT") { registrado = await _peopleService.RegisterDebtorTF(registroGuardar); } if (id == 2) { registrado = await _peopleService.RegisterSupplierTF(registroGuardar); } if (id == 3 || id == 4) { registrado = await _peopleService.RegisterFactorTF(registroGuardar); } if (registroGuardar.Participant == "BACKOFFICE" && ID == null) { registrado = await _peopleService.RegisterConfirmantTF(registroGuardar, token); } if (registroGuardar.Participant == "BACKOFFICE" && ID != null) { actualizado = await _peopleService.UpdateProfileTF(UpdateBank(registroGuardar, ID, "CONFIRMANT"), token); if (actualizado.Error == null) { registrado = "success: "; } else { registrado = actualizado.Error; } } if (registrado.Contains("success:")) { HttpContext.Session.SetString("registroDesemascarado", ""); } return(new JsonResult(registrado)); } else { return(new JsonResult(new { errorValidacion = result.Errors })); } }
public async Task <ApiResult <JwtToken> > Login(RequestRegister model, [FromQuery] string culture) { IUser user; Microsoft.AspNetCore.Identity.SignInResult result; switch (model.Type) { case 1: user = await _userService.FindByPhoneNumberAsync(model.Mobile); result = await _userService.LoginAsync(user, model.Password); break; case 2: if (!CheckVerCode(model.InternationalAreaCode + model.Mobile, model.VerCode, 0)) { throw ApiException.Common(RequestLocalizer["The verification code is incorrect or expired"]); } user = await _userService.FindByPhoneNumberAsync(model.Mobile); result = await _userService.LoginAsync(user); break; case 3: user = await _userService.FindByEmailAsync(model.Mail); result = await _userService.LoginAsync(user, model.Password); break; case 4: if (!CheckVerCode(model.Mail, model.VerCode, 1)) { throw ApiException.Common(RequestLocalizer["The verification code is incorrect or expired"]); } user = await _userService.FindByEmailAsync(model.Mail); result = await _userService.LoginAsync(user); break; case 0: default: user = await _userService.FindByNameAsync(model.UserName); result = await _userService.LoginAsync(user, model.Password); break; } if (result.Succeeded) { var jwtToken = HttpContext.Features.Get <JwtToken>(); return(ApiResult.Ok(jwtToken)); } throw ApiException.Common(RequestLocalizer["Wrong account or password"]); }
private void HandleUserRegistrationResult(NetworkPacket netPacket, string defaultChat, RequestRegister requestRegister, byte registerSuccess) { User user = new User(-1, "", null); switch (registerSuccess) { case RequestID.REGISTRATION_ACTION.RegisterSuccess: { /* * Add user to chat users list */ user = AddUserToUserList(requestRegister.Username, netPacket.WorkSocket); /* * Send registration request response to the user */ NetworkPacket response = new NetworkPacket(netPacket.WorkSocket, new RequestResponse(RequestID.RequestResponse, user.UserID, RequestID.RegisterRequestAction, registerSuccess).Serialize()); int result = networkManager.Send(response); AddUserToChat(netPacket, defaultChat, user); break; } case RequestID.REGISTRATION_ACTION.RegisterError: default: { /* * Send registration request response to the user */ NetworkPacket response = new NetworkPacket(netPacket.WorkSocket, new RequestResponse(RequestID.RequestResponse, user.UserID, RequestID.RegisterRequestAction, registerSuccess).Serialize()); int result = networkManager.Send(response); /* * Close user's socket on registration error */ netPacket.CloseSocket(); break; } } }