public async Task <ActionResult> Register(NormalUser user) { if (ModelState.IsValid) { normuser.UserName = user.UserName; normuser.Email = user.Email; normuser.UserPassword = user.UserPassword; CreateUsers users = new CreateUsers(); users.UserName = normuser.UserName; users.Email = normuser.Email; var resulter = await usmanager.CreateAsync(users, normuser.UserPassword); if (resulter.Succeeded) { return(RedirectToAction("SignIn", "Account")); } else { foreach (var item in resulter.Errors) { ModelState.AddModelError("", item.Description); } } } return(View((NormalUser)normuser)); }
public IActionResult Create([FromBody] CreateUsers usrToCreate) { User user = Data.Domain.Entities.User.Create(usrToCreate.Name, usrToCreate.IsAdmin, usrToCreate.Email, usrToCreate.Password, usrToCreate.Token, usrToCreate.Description); _repository.Add(user); return(Ok(user)); }
public void Configure(Action <SeederConfiguration, ConfigurationBuilder> action) { if (action == null) { throw new ArgumentNullException(nameof(action)); } var seederConfiguration = new SeederConfiguration(); var builder = new ConfigurationBuilder(); action.Invoke(seederConfiguration, builder); if (builder.Sources.Count == 0) { var environmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); builder .AddJsonFile("appsettings.json", true, true) .AddJsonFile($"appsettings.{environmentName}.json", true, true) .AddEnvironmentVariables(); } var configuration = builder.Build(); var args = Environment.GetCommandLineArgs(); ConnectionString = configuration.ToStringWithValue("Database:ConnectionStrings:DefaultConnection") .OverLoadString(seederConfiguration.ConnectionString, args, "-s", "--connectionStrings"); Database = configuration.ToStringWithValue("Database:ConnectionStrings:Name") .OverLoadString(seederConfiguration.Database, args, "-m", "--mongoName"); Path = configuration.ToStringWithValue("Files:Path", "", false) .OverLoadString(seederConfiguration.Path, args, "-p", "--path"); TimeReportSec = configuration.ToUint("TimeReportSec") .OverLoadUint(seederConfiguration.TimeReportSec, args, "-t", "--time"); DefaultCountSeed = configuration.ToUint("DefaultCountSeed") .OverLoadUint(seederConfiguration.DefaultCountSeed, args, "-n", "--number"); RewriteIndexes = configuration.ToBool("Database:RewriteIndexes"); HideDetailsInfo = configuration.ToBool("HideDetailsInfo"); ClearDataBeforeSeed = configuration.ToBool("ClearDataBeforeSeed"); CreateTags = configuration.ToBool("CreateTags"); CreateUsers = configuration.ToBool("CreateUsers"); Destination = configuration.ToStringWithValue("Destination") .OverLoadString(seederConfiguration.Destination.ToString(), args, "-d", "--destination").ToDestinationOption(DestinationOption.mg, true); if (!args.Any(a => a.Length < 20 && a.Contains("-"))) { return; } HideDetailsInfo = HideDetailsInfo.OverLoadBool(seederConfiguration.HideDetailsInfo, args, "-h", "--hide"); RewriteIndexes = RewriteIndexes.OverLoadBool(seederConfiguration.RewriteIndexes, args, "-r", "--rewrite"); ClearDataBeforeSeed = ClearDataBeforeSeed.OverLoadBool(seederConfiguration.ClearDataBeforeSeed, args, "-c", "--clear"); CreateTags = CreateTags.OverLoadBool(seederConfiguration.CreateTags, args, "--tags"); CreateUsers = CreateUsers.OverLoadBool(seederConfiguration.CreateUsers, args, "--users"); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. //public void Configure(IApplicationBuilder app, IHostingEnvironment env) public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ApplicationDbContext context, RoleManager <ApplicationRole> roleManager, UserManager <ApplicationUser> userManager, IConfiguration configuration ) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseMigrationsEndPoint(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } //Avoid CORS errors with JS files served over CDN app.UseCors(builder => builder.WithOrigins( "http://www.rwsservices.net", "https://www.rwsservices.net", "http://rwsservices.net", "https://rwsservices.net" ) .AllowAnyMethod() .AllowAnyHeader() ); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); }); //app.UseMvc(routes => //{ // routes.MapRoute( // name: "FileUpload", // template: "{controller=FileUpload}/{action=Index}/{id?}"); //}); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute("FileUpload", "{controller=FileUpload}/{action=Index}/{id?}"); }); CreateUsers.Initialize(context, userManager, roleManager, configuration).Wait(); // seed here DbInitializer.Initialize(context, userManager, roleManager).Wait(); // seed here }
public async Task Given_unique_email_user_should_be_created() { var email = "*****@*****.**"; var request = new CreateUsers { Email = email, UserName = "******", Password = "******" }; var response = await _client.PostAsync($"User/CreateUser", GetPayload(request)); response.StatusCode.Should().BeEquivalentTo(HttpStatusCode.Created); response.Headers.Location.ToString().Should().BeEquivalentTo($"User/{request.Email}"); //work now }
public MainProgram() { try { data_Import = Data_Import.Singleton(); if (!data_Import.CheckConnectionToDataBase()) { Environment.Exit(0); } //Widocznoś Maina dla Wszystkich. Self = this; //Pobranie danych z bazy dla dostępów osób logujących się do programy Access = data_Import.Load_Access(); //Tworzenie Użytkowanika CreateUsers NewUsers = new CreateUsers(Access); //Inicjalizowanie programu InitializeComponent(); action = new Action(this, data_Import); admin = new Admin(); summaryDetails = new SummaryDetails(); //Budowanie Formsa w zależności od uprawnień buildForm.Tab_Control_Add(Access, this, action, summaryDetails, admin, data_Import); if (ApplicationDeployment.IsNetworkDeployed) { toolStripStatusLabel1.Text = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString() + " Beta Version"; } else { toolStripStatusLabel1.Text = "0.5.0.40 Beta Portable Version"; } if (Environment.UserName.ToString() == "BartkKon") { string Link = data_Import.CheckLink(); toolStripStatusLabel1.Text = toolStripStatusLabel1.Text + " " + Link; } } catch (Exception ex) { LogSingleton.Instance.SaveLog(ex.Message); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. //public void Configure(IApplicationBuilder app, IHostingEnvironment env) public void Configure( IApplicationBuilder app, IWebHostEnvironment env, ApplicationDbContext context, RoleManager <ApplicationRole> roleManager, UserManager <ApplicationUser> userManager, IConfiguration configuration ) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseMigrationsEndPoint(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); }); //Ensure currencies and dates are set to GB var cultureInfo = new CultureInfo("en-GB"); //cultureInfo.NumberFormat.CurrencySymbol = "€"; CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; CreateUsers.Initialize(context, userManager, roleManager, configuration).Wait();// seed here }
static void Main(string[] args) { var createUsers = new CreateUsers(@"Server=tcp:authss.database.windows.net,1433;Initial Catalog=AuthSS_IdDb;Persist Security Info=False;User ID=authss_admin;Password=Welcome1@;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"); createUsers.CreateAdminUser(); }
public async Task <IActionResult> CreateUser([FromBody] CreateUsers user) { await _commandDispatcher.DispatchAsync(user); return(Created($"User/{user.Email}", null)); }
public void UserRegistrationTest() { #region Задание // Сценарий должен состоять из следующих частей: //1) регистрация новой учётной записи с достаточно уникальным адресом электронной почты(чтобы не конфликтовало с ранее созданными пользователями, в том числе при предыдущих запусках того же самого сценария), //2) выход(logout), потому что после успешной регистрации автоматически происходит вход, //3) повторный вход в только что созданную учётную запись, //4) и ещё раз выход. //В качестве страны выбирайте United States, штат произвольный.При этом формат индекса --пять цифр. //Можно оформить сценарий либо как тест, либо как отдельный исполняемый файл. //Проверки можно никакие не делать, только действия - заполнение полей, нажатия на кнопки и ссылки.Если сценарий дошёл до конца, то есть созданный пользователь смог выполнить вход и выход-- значит создание прошло успешно. #endregion GoToPageURL($"{baseUrl}en/create_account"); CreateUsers user = new CreateUsers("Masha", "Sasha", "Mankheton 77", "password2", "Las-Vegas"); // 1. Запонение формы user.EnterDataInput(driver, By.XPath(".//div[@id='create-account']//tr[2]/td[1]/input[@name='firstname']"), user.FirstName); Assert.IsNotNull(GetAttributeElement(By.XPath(".//div[@id='create-account']//tr[2]/td[1]/input[@name='firstname']"), "value")); user.EnterDataInput(driver, By.XPath(".//div[@id='create-account']//tr[2]/td[2]/input[@name='lastname']"), user.LastName); Assert.IsNotNull(GetAttributeElement(By.XPath(".//div[@id='create-account']//tr[2]/td[2]/input[@name='lastname']"), "value")); user.EnterDataInput(driver, By.XPath(".//div[@id='create-account']//tr[3]/td[1]/input[@name='address1']"), user.Address); Assert.IsNotNull(GetAttributeElement(By.XPath(".//div[@id='create-account']//tr[3]/td[1]/input[@name='address1']"), "value")); user.EnterDataInput(driver, By.XPath(".//div[@id='create-account']//tr[4]/td[1]/input[@name='postcode']"), user.Postcode); Assert.IsNotNull(GetAttributeElement(By.XPath(".//div[@id='create-account']//tr[4]/td[1]/input[@name='postcode']"), "value")); user.EnterDataInput(driver, By.XPath(".//div[@id='create-account']//tr[4]/td[2]/input[@name='city']"), user.City); Assert.IsNotNull(GetAttributeElement(By.XPath(".//div[@id='create-account']//tr[4]/td[2]/input[@name='city']"), "value")); // --------------------------------------------------------------------------------------------------- // Клик по элементу выпадающего списка PressClick(By.CssSelector("span [role='presentation']")); // В откр. списке ищем поле ввода user.EnterDataInput(driver, By.CssSelector("input.select2-search__field"), "United States"); // --------------------------------------------------------------------------------------------------- DropDownList(By.CssSelector("select[name='zone_code']"), rnd.Next(1, 65)); user.EnterDataInput(driver, By.XPath(".//div[@id='create-account']//tr[6]/td[1]/input[@name='email']"), user.Email); Assert.IsNotNull(GetAttributeElement(By.XPath(".//div[@id='create-account']//tr[6]/td[1]/input[@name='email']"), "value")); user.EnterDataInput(driver, By.XPath(".//div[@id='create-account']//tr[6]/td[2]/input[@name='phone']"), user.Phone); Assert.IsNotNull(GetAttributeElement(By.XPath(".//div[@id='create-account']//tr[6]/td[2]/input[@name='phone']"), "value")); user.EnterDataInput(driver, By.XPath(".//div[@id='create-account']//tr[8]/td[1]/input[@name='password']"), user.Password); Assert.IsNotNull(GetAttributeElement(By.XPath(".//div[@id='create-account']//tr[8]/td[1]/input[@name='password']"), "value")); user.EnterDataInput(driver, By.XPath(".//div[@id='create-account']//tr[8]/td[2]/input[@name='confirmed_password']"), user.Password); Assert.IsNotNull(GetAttributeElement(By.XPath(".//div[@id='create-account']//tr[8]/td[2]/input[@name='confirmed_password']"), "value")); //driver.FindElement(By.XPath(".//div[@id='create-account']//tr[8]/td[1]/input[@name='password']")).SendKeys(Keys.Control + "c" + user.Password); //driver.FindElement(By.XPath(".//div[@id='create-account']//tr[8]/td[2]/input[@name='confirmed_password']")).SendKeys(Keys.Control + "v"); PressClick(By.XPath(".//div[@id='create-account']//tr[9]//button[@name='create_account']")); // 2. Logout из аккаунта user.LogoutAccount(driver, By.XPath(".//div[@id='box-account']//li[last()]/a[.='Logout']")); Assert.IsTrue(GetAttributeElement(By.XPath(".//div[@id='box-account-login']/h3[@class='title']"), "textContent") == "Login"); // 3. Авторизация под пользователем user.EnterDataInput(driver, By.XPath(".//form[@name='login_form']//input[@name='email']"), user.Email); Assert.IsNotNull(GetAttributeElement(By.XPath(".//form[@name='login_form']//input[@name='email']"), "value")); user.EnterDataInput(driver, By.XPath(".//form[@name='login_form']//input[@name='password']"), user.Password); Assert.IsNotNull(GetAttributeElement(By.XPath(".//form[@name='login_form']//input[@name='password']"), "value")); PressClick(By.XPath(".//form[@name='login_form']//button[@name='login']")); // Проверяем, что зашли под пользователем Assert.IsTrue(GetAttributeElement(By.XPath(".//div[@id='box-account']/h3[@class='title']"), "textContent") == "Account"); // 4. Logout из аккаунта user.LogoutAccount(driver, By.XPath(".//div[@id='box-account']//li[last()]/a[.='Logout']")); // Проверяем, что вышли под пользователем Assert.IsTrue(GetAttributeElement(By.XPath(".//div[@id='box-account-login']/h3[@class='title']"), "textContent") == "Login"); }