public async Task <IActionResult> SignUp(SignUpViewModel model) { if (!ModelState.IsValid) { return(View(model)); } User user = new User() { Email = model.Email, UserName = model.Email }; IdentityResult res = await userManager.CreateAsync(user, model.Pswd); if (res.Succeeded) { await signInManager.SignInAsync(user, true); return(RedirectToAction("Index")); } else { foreach (var er in res.Errors) { ModelState.AddModelError("Email", er.Description); } return(View(model)); } return(View()); }
void RegistrationView_Loaded(object sender, RoutedEventArgs e) { _model = (SignUpViewModel)this.DataContext; _model.PasswordAccessor = () => Password.Password; _model.PasswordConfirmationAccessor = () => PasswordConfirmation.Password; _model.SignUpCompleted += _model_SignUpCompleted; }
public ActionResult AddEmployee(SignUpViewModel signUpViewModel) { try { var user = new User(); var employee = new Employee(); var signuphelper = new SignUpHelper(); user = signuphelper.GetUserobj(signUpViewModel); var result = _userService.Save(user); var userid = _userService.GetLastId(signUpViewModel.Email); signUpViewModel.UserId = userid.Data; employee = signuphelper.GetEmployeeobj(signUpViewModel); var result2 = _employeeService.Save(employee); if (result.HasError) { ViewBag.Message = result.Message; return(Content(result.Message)); } if (result2.HasError) { ViewBag.Message = result2.Message; return(Content(result2.Message)); } return(RedirectToAction("GetAllEmployee")); } catch (Exception e) { return(Content(e.Message)); } }
public SignUpPage() { InitializeComponent(); LastNameTB.Focus(); Keyboard.Focus(LastNameTB); DataContext = new SignUpViewModel(this); }
public ActionResult EmployeeDetails(int id) { try { var result = _employeeService.GetById(id); var result2 = _userService.GetById(id); DetailsViewModel details = new DetailsViewModel(); SignUpViewModel sg = new SignUpViewModel(); sg = details.SignUpViewModel(result.Data, result2.Data); if (result.HasError) { ViewBag.Message = result.Message; return(Content(result.Message)); } if (result2.HasError) { ViewBag.Message = result2.Message; return(Content(result2.Message)); } return(View(sg)); } catch (Exception e) { return(Content(e.Message)); } }
public async Task <IActionResult> SignUp(SignUpViewModel model) { if (ModelState.IsValid) { var user = new IdentityUser { UserName = model.Email, Email = model.Email }; var result = await userManager.CreateAsync(user, model.Password); if (result.Succeeded) { if (user.UserName == "*****@*****.**") { IdentityResult roleResult = await roleManager.CreateAsync(new IdentityRole("Admin")); result = await userManager.AddToRoleAsync(user, "Admin"); } await signInManager.SignInAsync(user, isPersistent : false); return(RedirectToAction("index", "home")); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } return(View(model)); }
public IActionResult UserForm(SignUpViewModel signUp) { _logger.LogInformation("POST request on UserForm."); if (ModelState.IsValid)//validates tour { // If valid, add the Party to the DB. Tour addTour = _repository.Tours .Where(t => t.TourId == signUp.TourId) .FirstOrDefault(); var party = new Party { EmailAddress = signUp.EmailAddress, PartyName = signUp.PartyName, PhoneNumber = signUp.PhoneNumber, PartySize = signUp.PartySize, Tour = addTour, TourId = signUp.TourId }; _context.Parties.Add(party); addTour.Parties.Add(party); _context.SaveChanges(); return(RedirectToAction("Index"));//if valid returns UserForm } // If invalid, render the model with errors. return(View(signUp)); }
public SignUpPage() { InitializeComponent(); var signUpViewModel = new SignUpViewModel(); signUpViewModel.OnSignUpResult += async(bool result) => { if (result) { await DisplayAlert("Sign Up Successful", "You'll soon be emailed with your MyMentor credentials.", "OK"); Navigation.InsertPageBefore(new LoginPage(), this); await Navigation.PopAsync(); } }; signUpViewModel.OnPrivacyPolicyClicked += async() => { await DisplayAlert("Privacy", "MyMentor uses your name for account verification and to better match you with other students and professors." + "\r\n\r\nYour personal information is private to you. If we ever plan to share this information, we will explicitly ask for your permission.", "OK"); }; BindingContext = signUpViewModel; }
internal SignUpView() { InitializeComponent(); var signUpViewModel = new SignUpViewModel(); DataContext = signUpViewModel; }
public async Task <IActionResult> SignUp(SignUpViewModel model) { try { await Mediator.Send(model.Command); HttpContext.Session.Set(SessionKeys.SignUpSuccess, Array.Empty <byte>()); return(RedirectToAction("SignIn", "Account")); } catch (AccountAlreadyExistException) { HttpContext.Session.Set(SessionKeys.AccountAlreadyExistError, Array.Empty <byte>()); } catch (PasswordsNotEqualException) { HttpContext.Session.Set(SessionKeys.PasswordsNotEqualError, Array.Empty <byte>()); } catch (Exception) { return(BadRequest()); } return(RedirectToAction("SignUp")); }
public async Task <IActionResult> SignUp(SignUpViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var user = new User { Email = model.Email, UserName = model.Email, FirstName = model.FirstName, LastName = model.LastName, MiddleName = model.MiddleName }; var created = await _userManager.CreateAsync(user, model.Password); if (created.Succeeded) { await _signInManager.SignInAsync(user, false); _logger.LogInformation("User success signup!"); return(RedirectToAction("Index", "Home")); } foreach (var error in created.Errors) { _logger.LogError("User don't signup!"); ModelState.AddModelError(String.Empty, error.Description); } return(View(model)); }
public ActionResult SignUp(SignUpViewModel model) { if (ModelState.IsValid) { using (DomainContext db = new DomainContext()) { var obj = db.Users.Where(a => a.EmailAddress.Equals(model.EmailAddress)).FirstOrDefault(); if (obj == null) { User user = new User(); user.FirstName = model.FirstName; user.LastName = model.LastName; user.EmailAddress = model.EmailAddress; user.PassWord = model.PassWord; db.Users.Add(user); db.SaveChanges(); return(RedirectToAction(actionName: "Index", controllerName: "Login")); } else if (obj != null) { model.SignupErrorMessage = "An account already exists with this email address"; return(View("Signup", model)); } } } return(View("Signup")); }
public async Task <IActionResult> SignUp(SignUpViewModel model, string returnUrl) { returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { var user = new AppUser { UserName = Guid.NewGuid().ToString(), Email = model.Email, FullName = model.FullName, EmailConfirmed = true, PhoneNumberConfirmed = true }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { await _userManager.AddToRoleAsync(user, Roles.Customer.ToString()); _logger.LogInformation("User created a new account with password."); await _signInManager.SignInAsync(user, isPersistent : false); return(RedirectToAction(nameof(HomeController.Index), nameof(HomeController))); } else { var errorList = new List <string>(); foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); errorList.Add(error.Description); } TempData["IdentityErrors"] = errorList.ToArray(); } } // If we got this far, something failed, redisplay form return(View(model)); }
public SignUpViewModel SignUp(SignUpActionData actionData) { var viewModel = new SignUpViewModel(); var modelStates = new ModelStateDictionary(); foreach (var reason in actionData.RegistrationFailureReasons) { switch (reason) { case RegistrationFailureReason.UsernameNotAvailable: modelStates.AddModelError("username", GetRegistrationFailureReasonText(RegistrationFailureReason.UsernameNotAvailable)); break; case RegistrationFailureReason.PasswordsDoNotMatch: modelStates.AddModelError("passwordConfirmation", GetRegistrationFailureReasonText(RegistrationFailureReason.PasswordsDoNotMatch)); break; case RegistrationFailureReason.EmailsDoNotMatch: modelStates.AddModelError("email", GetRegistrationFailureReasonText(RegistrationFailureReason.EmailsDoNotMatch)); break; default: throw new ArgumentOutOfRangeException(); } } IEnumerable <string> errors = actionData.RegistrationFailureReasons.Select(GetRegistrationFailureReasonText); viewModel.Errors = errors; viewModel.ModelState = modelStates; return(viewModel); }
public ActionResult SignUp(SignUpViewModel model) { if (model.Password != model.ConfirmPassword) { ModelState.AddModelError("ConfirmPassword", "Passwords don't match"); return(View(model)); } if (ModelState.IsValid) { try { UserEndpoint ue = new UserEndpoint(); ue.Register(model.UserName); WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { PrivateKey = string.Empty, PublicKey = string.Empty }); TempData["Notification"] = new Notification("Please check your e-mail, we sent you access keys.", Nature.success); return(RedirectToAction("Login")); } catch (Exception ex) { return(View("Error")); } } else { return(View(model)); } }
public async Task <IActionResult> SignUp([FromBody] SignUpViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var newUser = new ApplicationUser { Email = model.Email, Firstname = model.Firstname, Lastname = model.Lastname }; var result = await _userManager.CreateAsync(newUser, model.Password); if (!result.Succeeded) { return(BadRequest(result.Errors)); } ApplicationUser user = await _userManager.FindByEmailAsync(newUser.Email); var roles = await _userManager.GetRolesAsync(user); return(Ok(_tokenService.Generate(user, roles.ToList()))); }
public ActionResult SignUp(SignUpViewModel signUpViewModel) { this.InitializeFacebookAuth(Url.Action("OAuthLogin", "Auth", null, "https")); if(!this.ValidateAndAppendMessages(signUpViewModel)) { return View("Login"); } if(this.UserService.EmailAddressIsInUse(signUpViewModel.NewUserEmailAddress)) { this.AppendMessage(new ErrorMessage { Text = "The email address you entered is already registered" }); return View("Login"); } try { var user = this.CreateAccount(signUpViewModel); this.ForwardMessage(new SuccessMessage { Text = "Your account has been created. Welcome to Brewgr!" }); return this.SignInAndRedirect(user); } catch (Exception ex) { this.LogHandledException(ex); this.AppendMessage(new ErrorMessage { Text = GenericMessages.ErrorMessage }); return View("Login"); } }
public async Task <IActionResult> SignUp(SignUpViewModel signUpModel) { if (ModelState.IsValid) { UserModel user = await _userManager.FindByEmailAsync(signUpModel.Email); if (user == null) { user = new UserModel(); user.UserName = signUpModel.Email; user.Email = signUpModel.Email; var result = await _userManager.CreateAsync(user, signUpModel.Password); if (result.Errors.Count() > 0) { foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } return(View()); } return(RedirectToAction("Signin")); } ModelState.AddModelError("Email", "Email has already been taken"); return(View()); } return(View()); }
public SignUpPage() { this.InitializeComponent(); ViewModel = new SignUpViewModel(); DataContext = ViewModel; }
public async Task <ActionResult> SignUpUser(SignUpViewModel user) { if (ModelState.IsValid) { var appUser = new AppUser { UserName = user.Email, Email = user.Email, }; var result = await _userManager.CreateAsync(appUser, user.Password); if (result.Succeeded) { // **Uncomment this line of code when you want to generate an new claim(type Role) to a user. Then, run the Application and SignUp.** //await _userManager.AddClaimAsync(appUser, new Claim(ClaimTypes.Role, RoleName.Admin)); await _signInManager.SignInAsync(appUser, isPersistent : false); return(RedirectToAction("IndexWhenAuthenticated", "Home")); } foreach (var identityError in result.Errors) { ModelState.AddModelError(identityError.Code, identityError.Description); } } return(View(user)); }
public SignUpPage(SignUpViewModel signUpViewModel) { InitializeComponent(); Init(); SignUpViewModel = signUpViewModel; this.BindingContext = SignUpViewModel; }
//TODO: Figure out how to combine logic with Index public ActionResult SignUp(SignUpViewModel model) { ViewBag.Description = "Sign up for How-to's, life hacks and insight into .NET, C#, The Web, Open Source, Programming and more from Chad Ramos. Brought to you by Pioneer Code."; ViewBag.PopularPosts = _postService.GetPopularPosts().ToList(); ViewBag.LatestPosts = _postService.GetAll(true, false, false, 8).ToList(); if (!ModelState.IsValid) { ViewBag.IsValid = false; return(View("Index", model)); } //var response = _communicationService.SignUpToMailingList(model); //if (response.Status != OperationStatus.Created) //{ // ViewBag.IsValid = false; // ViewBag.IsValidMessage = response.Message; // return View("Index", model); //} ViewBag.IsValid = true; return(View("Index", model)); }
public SignUp() { InitializeComponent(); SignUpViewModel = new SignUpViewModel(); //set binding BindingContext = SignUpViewModel; }
public bool SignUp(SignUpViewModel signUpViewModel) { var userPasswordDto = new UserPasswordDto { user = new UserPasswordDto.User { userName = signUpViewModel.Username, email = signUpViewModel.Email, emailConfirmed = true, phoneNumber = signUpViewModel.Phone, phoneNumberConfirmed = true }, password = new UserPasswordDto.Password { password = signUpViewModel.Password, confirmPassword = signUpViewModel.Password } }; var token = GetAdminToken(); var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Add("Authorization", "bearer " + token); var serializedUserPassword = serializerService.Serialize(userPasswordDto); var httpContent = new StringContent(serializedUserPassword, Encoding.UTF8, "application/json"); var result = httpClient.PostAsync("https://petshop-sergio-iammicroservice-api.azurewebsites.net/api/UsersAndRoles", httpContent).Result; if (!result.IsSuccessStatusCode) { return(false); } return(true); }
public SignUpResult SignUp(SignUpViewModel signUpViewModel) { var request = new RestSharp.RestRequest(AccountAPI.SignUp) { JsonSerializer = new NewtonsoftJsonSerializer() }; request.AddJsonBody(signUpViewModel); var user = new User(); IRestResponse response = _client.Post(request); var json = JsonConvert.DeserializeObject <GenericAPIResponse>(response.Content); if (json.success) { user = new User() { UserName = signUpViewModel.UserName, PasswordHash = signUpViewModel.Password, Email = signUpViewModel.Email, UserId = signUpViewModel.UserId }; } return(new SignUpResult() { Succeed = json.success, ErrorMessage = json.error, user = user }); }
public ActionResult EditProfile(SignUpViewModel viewModel) { try { ModelState.Remove("FirstName"); ModelState.Remove("LastName"); ModelState.Remove("Email"); ModelState.Remove("Sex"); ModelState.Remove("Password"); ModelState.Remove("Age"); if (ModelState.IsValid) { Entity.USER user = GetUserById(viewModel.UserId); if (user != null) { user.Address = viewModel.Address; user.CreditCardNumber = viewModel.CreditCardNumber; user.PhoneNumber = viewModel.PhoneNumber; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); SetMessage(new Message() { MessageText = "Profile was edited succesfully", MessageCategory = (int)MessageCategory.SUCCESS }); } } return(View(viewModel)); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> SignUp(SignUpViewModel model) { if (ModelState.IsValid) { await signInManager.SignOutAsync(); var result = await userManager.FindByEmailAsync(model.Email); if (result == null) { ApplicationUser user = new ApplicationUser { UserName = model.UserName, Email = model.Email }; if ((await userManager.CreateAsync(user, model.Password)) .Succeeded) { await userManager.AddToRoleAsync(user, Roles.User); await signInManager.PasswordSignInAsync(user, model.Password, false, false); return(Redirect("/Profile/Index")); } } } var error = $"A user with the email {model.Email} is already registered."; ModelState.AddModelError("", error); TempData["message"] = error; return(View(model)); }
public async Task <IActionResult> SignUpAsync(SignUpViewModel model) { var user = new ApplicationUser { Email = model.EmailAddress, UserName = model.UserName }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { // Get database user in order to get userId user = await _userManager.FindByEmailAsync(model.EmailAddress); return(new JsonResult(new { user.Email, user.UserName, user.Id })); } return(BadRequest(JsonSerializer.Serialize(result.Errors.ToArray()))); }
public async Task <ActionResult> SignUp(SignUpViewModel model) { if (ModelState.IsValid) { var user = new AppUser { UserName = model.UserName, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { // --- Sign in the user await SignInManager.SignInAsync(user, false, false); // --- Create the subscription for the user var subscrSrv = ServiceManager.GetService <ISubscriptionService>(); var newSubscr = new SubscriptionDto { SubscriberName = user.UserName, PrimaryEmail = user.Email, CreatedUtc = DateTimeOffset.UtcNow, }; var subscriptionId = await subscrSrv.CreateSubscriptionAsync(newSubscr, user.Id); CreateAuthenticationTicket(false, new Guid(user.Id), user.UserName, false, subscriptionId, true); return(RedirectToAction("SelectSubscriptionPackage")); } AddErrors(result); } return(View(model)); }
public async Task <IActionResult> SignUp(SignUpViewModel model) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Logs", "Home")); } if (!ModelState.IsValid) { return(View(model)); } AppUser u = new() { Email = model.Email, UserName = model.UserName, DailyTarget = model.DailyTarget }; var res = await _appUsersService.CreateAsync(u, model.Password); if (res.Succeeded) { _signinService.SessionLogin(u); return(RedirectToAction("Logs", "Home")); } else { res.Errors.ForEach(e => ModelState.AddModelError("", e)); return(View(model)); } }
public ActionResult UpdateEmployee(SignUpViewModel signUp) { try { var employeeobj = _employeeService.GetById(signUp.UserId); var userobj = _userService.GetById(signUp.UserId); var update = new UpdateInstance(); var updateUser = update.GetUpdatedUserObj(signUp, userobj.Data); var result = _userService.Save(updateUser); var updateEmployee = update.GetUpdatedEmployeeObj(signUp, employeeobj.Data); var result2 = _employeeService.Save(updateEmployee); if (result.HasError) { ViewBag.Message = result.Message; return(Content(result.Message)); } if (result2.HasError) { ViewBag.Message = result.Message; return(Content(result.Message)); } return(RedirectToAction("GetAllEmployee")); } catch (Exception e) { return(Content(e.Message)); } }
/// <summary> /// Регистрация. /// </summary> public async Task <Guid> SignUpAsync(SignUpViewModel model) { if (await _userRepository.GetByEmailAsync(model.Email) != null) { throw new Exception($"Username '{model.Email}' is already in use."); } try { var user = _mapper.Map <User>(model); user.Password = _passwordHashService.GetHash(user.Password); user.ConfirmCode = Guid.NewGuid().ToString("N"); var userId = await _userRepository.InsertAsync(user); var confirmUrl = $"/api/account/confirm/{user.ConfirmCode}"; await _notificationService.SendAccountConfirmationAsync(user.Email, confirmUrl); return(userId); } catch (Exception e) { throw new Exception(e.Message); } }
public override void ViewDidLoad () { base.ViewDidLoad (); viewModel = App.SignUpViewModel; resigner = new FirstResponderResigner (View, Input); #if DEBUG // debugGesture = new TapGestureAttacher (View, 3, ChangeThemeProps); debugGesture = new TapGestureAttacher (View, 3, Theme.SetNextTheme); #endif ContinueBtn.TouchUpInside += ContinueHandler; SwitchSignUpType.TouchUpInside += SwitchSignUpTypeHandler; Input.EditingChanged += InputChangedHandler; NickName.EditingChanged += NickNameInputHandler; SausageButtons.SetUp (ContinueBtn); SausageButtons.SetUp (SwitchSignUpType); SwitchSignUpType.Layer.BorderWidth = 1.5f; #region Theme switcher BoyButton.SetTitle("Red", UIControlState.Normal); GirlButton.SetTitle("Blue", UIControlState.Normal); BoyButton.TouchUpInside += RedThemeSelected; GirlButton.TouchUpInside += BlueThemeSelected; ThemeSelectorContainerView.BackgroundColor = Theme.Current.BackgroundColor; SausageButtons.SetUp (BoyButton); SausageButtons.ApplyTheme(AppDelegate.RedTheme, BoyButton); SausageButtons.UpdateBackgoundColor(AppDelegate.RedTheme, BoyButton); SausageButtons.SetUp (GirlButton); SausageButtons.ApplyTheme(AppDelegate.BlueTheme, GirlButton); SausageButtons.UpdateBackgoundColor(AppDelegate.BlueTheme, GirlButton); #endregion UpdateText (); }
public ActionResult SignUp(SignUpViewModel signUp) { if (ModelState.IsValid) { var createClient = new CreateClientCommand(signUp.Name, signUp.Email, signUp.Password, signUp.Brag, signUp.Latitude, signUp.Longitude, signUp.Source.Value); ExecuteCommand(createClient); _userMailer.Welcome(signUp.Name, createClient.EmailVerificationCode, signUp.Email).Send(); return RedirectToAction("SignUpSuccess"); } return View(); }
/// <summary> /// Creates a new Account /// </summary> UserSummary CreateAccount(SignUpViewModel signUpViewModel) { using (var unitOfWork = this.UnitOfWorkFactory.NewUnitOfWork()) { var user = this.UserService.RegisterNewUser(signUpViewModel.NewUserFullName, signUpViewModel.NewUserEmailAddress, signUpViewModel.NewUserPassword); unitOfWork.Commit(); // TODO: We need to send a welcome email return Mapper.Map(user, new UserSummary()); } }
public ViewResult SignUpViaDialog(SignUpViewModel signUpViewModel) { this.InitializeFacebookAuth(Url.Action("OAuthLogin", "Auth", null, "https")); if (!this.ValidateAndAppendMessages(signUpViewModel)) { ViewBag.LoginViaDialogSuccess = false; return View("LoginViaDialog"); } if (this.UserService.EmailAddressIsInUse(signUpViewModel.NewUserEmailAddress)) { ViewBag.LoginViaDialogSuccess = false; this.AppendMessage(new ErrorMessage { Text = "The email address you entered is already registered" }); return View("LoginViaDialog"); } try { var userSummary = this.CreateAccount(signUpViewModel); ViewBag.LoginViaDialogSuccess = true; this.SignIn(userSummary, false); this.AppendLoginViaDialogSuccessMessage(userSummary, !string.IsNullOrWhiteSpace(Request["editMode"])); } catch (Exception ex) { this.LogHandledException(ex); this.AppendMessage(new ErrorMessage { Text = GenericMessages.ErrorMessage }); } return View("LoginViaDialog"); }
/// <summary> /// Creates a new Account /// </summary> UserSummary CreateAccount(SignUpViewModel signUpViewModel) { using (var unitOfWork = this.UnitOfWorkFactory.NewUnitOfWork()) { var user = this.UserService.RegisterNewUser(signUpViewModel.NewUserFullName, signUpViewModel.NewUserEmailAddress, signUpViewModel.NewUserPassword); unitOfWork.Commit(); // Send the Email Message var newAccountEmailMessage = (NewAccountEmailMessage)this.EmailMessageFactory.Make(EmailMessageType.NewAccount); newAccountEmailMessage.ToRecipients.Add(signUpViewModel.NewUserEmailAddress); this.EmailSender.Send(newAccountEmailMessage); return Mapper.Map(user, new UserSummary()); } }