public async Task <ActionResult> Register(RegistrationViewModel registrationModel) { var model = new LoginViewModel(new SigninViewModel(registrationModel.ReturnUrl), registrationModel); if (!ModelState.IsValid) { return(View("Login", model)); } if (await _clientAccountsRepository.IsTraderWithEmailExistsAsync(registrationModel.Email)) { ModelState.AddModelError("", $"Email {registrationModel.Email} is already in use."); return(View("Login", model)); } string userIp = this.GetIp(); string referer = null; string userAgent = this.GetUserAgent(); if (!string.IsNullOrEmpty(registrationModel.Referer)) { referer = new Uri(registrationModel.Referer).Host; } RegistrationResponse result = await _registrationClient.RegisterAsync(new RegistrationModel { Email = registrationModel.Email, Password = PasswordKeepingUtils.GetClientHashedPwd(registrationModel.RegistrationPassword), Ip = userIp, Changer = RecordChanger.Client, UserAgent = userAgent, Referer = referer }); if (result == null) { ModelState.AddModelError("", "Technical problems during registration."); return(View("Login", model)); } var clientAccount = new Core.Clients.ClientAccount { Id = result.Account.Id, Email = result.Account.Email, Registered = result.Account.Registered, NotificationsId = result.Account.NotificationsId, Phone = result.Account.Phone }; foreach (var registrationConsumer in _registrationConsumers) { registrationConsumer.ConsumeRegistration(clientAccount, userIp, CultureInfo.CurrentCulture.Name); } var identity = await _userManager.CreateUserIdentityAsync(clientAccount.Id, clientAccount.Email, registrationModel.Email); await HttpContext.Authentication.SignInAsync("ServerCookie", new ClaimsPrincipal(identity), new AuthenticationProperties()); return(RedirectToAction("PersonalInformation", "Profile", new { returnUrl = registrationModel.ReturnUrl })); }
public static IClientAccount RegisterClient(this IoC ioc, string email, string password = "******") { var clientAccount = new ClientAccount { Email = email, Phone = "+7999222444555", Registered = DateTime.UtcNow }; return ioc.GetObject<IClientAccountsRepository>().RegisterAsync(clientAccount, password).Result; }
public static IClientAccount RegisterTrader(this IoC ioc, string email) { var trader = new ClientAccount {Email = email}; return ioc.GetObject<IClientAccountsRepository>().RegisterAsync(trader, "123").Result; }