//Post call for Login functionality public async Task <object> PostUserRegistrationDataAsync(UserRegistrationRequestModel loginRequest) { string requestUri = string.Empty; //= $"{Constant.BASE_URI}{Constant.LOGIN_API}"; string jsonInput = JsonConvert.SerializeObject(loginRequest); return(await PostDataAsync <UserRegistrationResponseModel>(new Uri(requestUri), jsonInput)); }
private async Task CreateAccount() { IsBusy = true; var user = new UserRegistrationRequestModel( StringUtils.RemoveWhiteSpaces(FormModelList[2].TextFieldValue), FormModelList[5].TextFieldValue, StringUtils.RemoveWhiteSpaces(FormModelList[0].TextFieldValue), StringUtils.RemoveWhiteSpaces(FormModelList[1].TextFieldValue), FormModelList[3].TextFieldValue ); if (!CheckForm(user)) { IsBusy = false; return; } user.FirstName = StringUtils.FirstCharToUpper(user.FirstName); user.LastName = StringUtils.FirstCharToUpper(user.LastName); try { var result = await _authService.CreateAccount(user); if (result.StatusCode == 207) { AppSettings.Logout(); _settingsService.Logout(); AppSettings.UserEmail = user.Email; await SecureStorage.SetAsync("password", user.Password); await NavigationService.NavigateAsync <LoginViewModel, object>(null); await CloseView(); await NavigationService.NavigateAsync <ActivateAccountViewModel, string>(user.Email); await Task.Delay(TimeSpan.FromSeconds(0.8f)); _dialogService.ShowAlert(_statusService.GetStatusCodeDescription(result.StatusCode), AlertType.Success, 8f); } else { _dialogService.ShowAlert(_statusService.GetStatusCodeDescription(result.StatusCode), AlertType.Error); } } catch (Exception ex) { Ui.Handle(ex as dynamic); } finally { IsBusy = false; } }
private User MapUserRequestModelToUserModel(UserRegistrationRequestModel oUserRequestModel) { User oUser = new Models.User(); oUser.FirstName = oUserRequestModel.first_name; oUser.LastName = oUserRequestModel.last_name; oUser.PhoneNumber = oUserRequestModel.phone_number; oUser.Email = oUserRequestModel.email_address; return(oUser); }
public async Task <IdentityResult> Register(UserRegistrationRequestModel registrationRequest) { ApplicationUser applicationUser = new ApplicationUser() { Email = registrationRequest.Email, UserName = registrationRequest.Email, FirstName = registrationRequest.FirstName, LastName = registrationRequest.LastName }; return(await this._userManager.CreateAsync(applicationUser, registrationRequest.Password)); }
public async Task <IActionResult> Register([FromBody] UserRegistrationRequestModel model) { IdentityResult registrationResult = await this._authorizationService.Register(model); if (!registrationResult.Succeeded) { this.ModelState.AddIdentityErrors(registrationResult); return(this.BadRequest(this.ModelState)); } return(this.StatusCode((int)HttpStatusCode.Created)); }
private bool CheckForm(UserRegistrationRequestModel user) { if (ReflectionHelper.HasEmptyOrNullValues(user)) { _dialogService.ShowAlert(EmptyForm, AlertType.Error); return(false); } if (!StringUtils.CheckForEmojis(user.Password) || !StringUtils.CheckForEmojis(user.FirstName) || !StringUtils.CheckForEmojis(user.LastName)) { _dialogService.ShowAlert(DamnEmojis, AlertType.Error, 6f); return(false); } if (!StringUtils.IsLettersOnly(user.FirstName) || !StringUtils.IsLettersOnly(user.LastName)) { _dialogService.ShowAlert(InvalidString, AlertType.Error, 6.5f); return(false); } if (!EmailUtils.IsValidEmail(StringUtils.RemoveWhiteSpaces(user.Email))) { _dialogService.ShowAlert(InvalidEmail, AlertType.Error); return(false); } if (user.Password.Length < 8) { _dialogService.ShowAlert(PasswordWeak, AlertType.Error, 6f); return(false); } if (user.Password != FormModelList[4].TextFieldValue) { _dialogService.ShowAlert(PasswordMatch, AlertType.Error, 3.5f); return(false); } if (user.Phone.Length > 16 || user.Phone.Length < 8) { _dialogService.ShowAlert(AlertPhoneNumber, AlertType.Error, 3.5f); return(false); } if (!_userAgreed) { _dialogService.ShowAlert(UserAgreement, AlertType.Error); return(false); } return(true); }
public async Task <IHttpActionResult> PostUser(UserRegistrationRequestModel oUserRequestModel) { string sIPAddress = Request.GetOwinContext().Request.RemoteIpAddress; try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } bool blnIsEmailValid = ValidateEmailExists(oUserRequestModel.email_address); if (!blnIsEmailValid) { return(BadRequest("E-mail address already exists")); } if (!oUserRequestModel.password.Equals(oUserRequestModel.password_confirm)) { return(BadRequest("Passwords Do not Match")); } if (!oUserRequestModel.password.Any(p => char.IsUpper(p)) && !oUserRequestModel.password_confirm.Any(cp => char.IsUpper(cp))) { return(BadRequest("Passwords Don't Contain An Uppercase Letter")); } User user = oUserRegistration.CheckUserRegistration(oUserRequestModel); try { await oUserRepo.SaveUser(user); Auth0TokenReturnModel Auth0User = JsonConvert.DeserializeObject <Auth0TokenReturnModel>(oAuth0Users.CreateAuth0User(oUserRequestModel.email_address, oUserRequestModel.password)); user.EmailConfirmed = Auth0User.email_verified; user.Auth0Identifier = Auth0User.user_id; user.CreationDate = Convert.ToDateTime(Auth0User.created_at); await oUserRepo.UpdateUserAfterRegistration(user); } catch (DbUpdateException) { if (UserExists(user.Id)) { return(Conflict()); } else { return(InternalServerError()); } } return(CreatedAtRoute("DefaultApi", new { stripeCustId = user.StripeIdentifier }, user)); } catch (Exception ex) { oLogger.LogData("ROUTE: api/Users; METHOD: POST; IP_ADDRESS: " + sIPAddress + "; EXCEPTION: " + ex.Message + "; INNER EXCEPTION: " + ex.InnerException); return(InternalServerError()); } }
public async Task <BaseModel> CreateAccount(UserRegistrationRequestModel userAccount) { return(await _webService.PostAsync <BaseModel>("registration/add", userAccount, needsHeaderCheck : false).ConfigureAwait(false)); }
public async Task <IHttpActionResult> Registration(UserRegistrationRequestModel model) { if (!ModelState.IsValid) { return(BadRequest()); } try { var isUserExist = await userReadService.IsUserExistAsync(model.Email); if (isUserExist) { return(BadRequest("User is already registered")); } else { //registration var chain = new Chain { CreatedOn = DateTime.UtcNow }; var user = new User { Email = model.Email, Password = userWriteService.HashPassword(model.Password), Name = model.Name, Surname = model.Surname, Birthday = model.Birthday, LeagueId = model.LeagueId, RegistrationDate = DateTime.UtcNow, Chain = chain }; var newUser = await userWriteService.RegistrationAsync(user); //add history var maxId = await chainReadService.GetMaxBlocksIdAsync(); var block = new HistoryBlock { Id = ++maxId, Changes = "User registration", AuthorId = newUser.Id, CreatedOn = DateTime.UtcNow.Date }; block.Hash = block.HashValues(); var newBlock = await chainWriteService.AddHistoryBlockToChainAsync(newUser.Chain.Id, block); //sign in var identity = SignIn(newUser.Email, newUser.Role.Value, newUser.Id.ToString()); var token = GetUserToken(identity); return(Ok(new { token, newUser.Id, newUser.RoleId })); } } catch (Exception ex) { return(InternalServerError(ex)); } }