protected void Button1_Click(object sender, EventArgs e) { UserStore <IdentityUser> userStore = new UserStore <IdentityUser>(); userStore.Context.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["GameCenterDBConnectionString"].ConnectionString; UserManager <IdentityUser> manager = new UserManager <IdentityUser>(userStore); //create new user and try to store in DB IdentityUser user = new IdentityUser(); user.UserName = txtUserName.Text; if (txtPassword.Text == txtConfirmPassword.Text) { try { //create user object //database will be created / expanded automatically IdentityResult result = manager.Create(user, txtPassword.Text); if (result.Succeeded) { UserInformation info = new UserInformation { Address = txtAddress.Text, FirstName = txtFisrtName.Text, LastName = txtLastName.Text, PostalCode = Convert.ToInt32(txtPostalCode.Text), GUID = user.Id }; UserInfoModel model = new UserInfoModel(); model.InsertUserInformation(info); //insert user information //store user in database var authentificationManager = HttpContext.Current.GetOwinContext().Authentication; //set to log in new user by cookie var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); //log in the new user and redirect to homepage authentificationManager.SignIn(new AuthenticationProperties(), userIdentity); Response.Redirect("~/Index.aspx"); } else { litStauts.Text = result.Errors.FirstOrDefault(); } } catch (Exception ex) { litStauts.Text = ex.ToString(); } } else { litStauts.Text = "Passwords must match"; } }
protected void Button1_Click(object sender, EventArgs e) { if ((txtPassword.Text).Equals(txtConfrmPassword.Text)) { UserInfoModel model = new UserInfoModel(); UserInformation info = new UserInformation(); Guid g = Guid.NewGuid(); info.GUID = g.ToString(); info.FirstName = txtFirstname.Text; info.LastName = txtLastName.Text; info.Address = txtAddress.Text; info.Username = txtUsername.Text; info.Password = txtPassword.Text; info.PostalCode = Convert.ToInt32(txtPostalCode.Text); info.IsVerified = false; info.Email = txtEmail.Text; info.Phone = Convert.ToInt64(txtPhone.Text); info.SecretAnswer = txtAns.Text; model.InsertUserInformation(info); litStatus.Text = "Registration Successful"; } else { litStatus.Text = "Both password should be same"; } }
protected void Button1_Click(object sender, EventArgs e) { UserStore <IdentityUser> userStore = new UserStore <IdentityUser>(); userStore.Context.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ShopDBConnectionString"].ConnectionString; UserManager <IdentityUser> manager = new UserManager <IdentityUser>(userStore); //Tworzenie nowego usera IdentityUser user = new IdentityUser(); user.UserName = txtUserName.Text; if (txtPassword.Text == txtConfirmPassword.Text) { try { //utworz obiekt użytkownika //baza danych zostanie utworzona automatycznie IdentityResult result = manager.Create(user, txtPassword.Text); if (result.Succeeded) { UserInformation info = new UserInformation { Address = txtAddress.Text, FirstName = txtFirstName.Text, LastName = txtLastName.Text, PostalCode = Convert.ToInt32(txtPostalCode.Text), GUID = user.Id }; UserInfoModel model = new UserInfoModel(); model.InsertUserInformation(info); //Przechowywanie użytkownika w bazie danych var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; //nowy użytkownik, ciasteczka var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); //zaloguj sie jako nowy użytkownik i przekieruj na stronę główną authenticationManager.SignIn(new AuthenticationProperties(), userIdentity); Response.Redirect("~/Index.aspx"); } else { litStatus.Text = result.Errors.FirstOrDefault(); } } catch (Exception ex) { litStatus.Text = ex.ToString(); } } else { litStatus.Text = "Hasło musi być takie samo"; } }
protected void Button1_Click(object sender, EventArgs e) { //create database with new users UserStore <IdentityUser> userstore = new UserStore <IdentityUser>(); //merge with our database userstore.Context.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ShopConnectionString"].ConnectionString; UserManager <IdentityUser> mamger = new UserManager <IdentityUser>(userstore); //create new user and store db IdentityUser user = new IdentityUser(); user.UserName = TextBox1.Text; if (TextBox2.Text == TextBox3.Text) { try { //create user object //db will be created IdentityResult res = mamger.Create(user, TextBox2.Text); if (res.Succeeded) { UserInformation info = new UserInformation { FirstName = TextBox4.Text, LastName = TextBox5.Text, Address = TextBox6.Text, PostalCard = Convert.ToInt32(TextBox7.Text), GUID = user.Id }; UserInfoModel model = new UserInfoModel(); model.InsertUserInformation(info); //store user in db var authenticationmanager = HttpContext.Current.GetOwinContext().Authentication; //set to log in new user by cookie var userIdentity = mamger.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); // log in the new user and redirect to home page authenticationmanager.SignIn(new AuthenticationProperties(), userIdentity); Response.Redirect("~/Index.aspx"); } else { Literal1.Text = res.Errors.FirstOrDefault(); } } catch (Exception d) { Literal1.Text = d.ToString(); } } else { Literal1.Text = "Password don't match"; } }
protected void Button1_Click(object sender, EventArgs e) { UserStore <IdentityUser> userStore = new UserStore <IdentityUser>(); userStore.Context.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager. ConnectionStrings["RestaurantDBConnectionString"].ConnectionString; UserManager <IdentityUser> manager = new UserManager <IdentityUser>(userStore); IdentityUser user = new IdentityUser(); user.UserName = txtUserName.Text; if (txtPassword.Text == txtConfirmPassword.Text) { try { IdentityResult result = manager.Create(user, txtPassword.Text); if (result.Succeeded) { UserInformation info = new UserInformation { Address = txtAddress.Text, FirstName = txtFirstName.Text, LastName = txtLastName.Text, PostalCode = Convert.ToInt32(txtPostalCode.Text), GUID = user.Id }; UserInfoModel model = new UserInfoModel(); model.InsertUserInformation(info); var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); authenticationManager.SignIn(new AuthenticationProperties(), userIdentity); Response.Redirect("~/Index.aspx"); } else { litStatus.Text = result.Errors.FirstOrDefault(); } } catch (Exception ex) { litStatus.Text = ex.ToString(); } } else { litStatus.Text = "Пароли не совпадают!"; } }
protected void btnRegister_Click(object sender, EventArgs e) { // Default UserStore constructor uses the default connection string named: DefaultConnection UserStore <IdentityUser> userStore = new UserStore <IdentityUser>(); //Set ConnectionString to GarageConnectionString userStore.Context.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["GarageDBConnectionString"].ConnectionString; var manager = new UserManager <IdentityUser>(userStore); //Create new user and try to store in DB. var user = new IdentityUser(); user.UserName = txtUserName.Text; if (txtPassword.Text == txtConfirmPassword.Text) { try { IdentityResult result = manager.Create(user, txtPassword.Text); if (result.Succeeded) { UserInformation info = new UserInformation { Address = txtAddress.Text, FirstName = txtFirstName.Text, LastName = txtLastName.Text, GUID = user.Id, PostalCode = Convert.ToInt32(txtPostalCode.Text) }; UserInfoModel model = new UserInfoModel(); model.InsertUserInformation(info); //Store user in DB var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); //If succeedeed, log in the new user and set a cookie and redirect to homepage authenticationManager.SignIn(new AuthenticationProperties(), userIdentity); Response.Redirect("/Index.aspx"); } else { litStatusMessage.Text = result.Errors.FirstOrDefault(); } } catch (Exception ex) { litStatusMessage.Text = ex.ToString(); } } else { litStatusMessage.Text = "Passwords must match!"; } }
protected void Button1_Click(object sender, EventArgs e) { UserStore<IdentityUser> userStore = new UserStore<IdentityUser>(); userStore.Context.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["CANDZOILPDBConnectionString"].ConnectionString; UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore); IdentityUser user = new IdentityUser(); user.UserName = txtUserName.Text; if (txtPassword.Text.Equals(txtConfirmPassword.Text)) { try { IdentityResult result = manager.Create(user, txtPassword.Text); if (result.Succeeded) { UserInformation info = new UserInformation { Address = txtAddress.Text, FirstName = txtFirstName.Text, LastName = txtLastName.Text, PostalCode = Convert.ToInt32(txtPostalCode.Text), GUID = user.Id }; UserInfoModel model = new UserInfoModel(); model.InsertUserInformation(info); var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); authenticationManager.SignIn(new AuthenticationProperties(), userIdentity); Response.Redirect("~/Index.aspx"); }else{ litStatusMessage.Text = result.Errors.FirstOrDefault(); } } catch (Exception er) { litStatusMessage.Text = er.ToString(); } } else { litStatusMessage.Text = "Passwords must match!"; } }
protected void Button1_Click(object sender, EventArgs e) { UserStore <IdentityUser> userStore = new UserStore <IdentityUser>(); userStore.Context.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings ["Ukrainian_delicacyConnectionString"].ConnectionString; UserManager <IdentityUser> manager = new UserManager <IdentityUser>(userStore); //Dodati novog korisnika i pohraniti u DB IdentityUser user = new IdentityUser(); user.UserName = txtUserName.Text; if (txtPassword.Text == txtConfirmPass.Text) { //Create user objekt try { IdentityResult result = manager.Create(user, txtPassword.Text); if (result.Succeeded) { UserInformation info = new UserInformation { FirstName = TxtFirstName.Text, LastName = TxtLastName.Text, Address = TxtAddress.Text, PostalCode = Convert.ToInt32(TxtPostCode.Text), GUID = user.Id }; UserInfoModel model = new UserInfoModel(); model.InsertUserInformation(info); //Store user in DB var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; //Set to login user by coockie var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); //Login new user and redirect to homepage authenticationManager.SignIn(new Microsoft.Owin.Security.AuthenticationProperties(), userIdentity); Response.Redirect("~/Pages/Default.aspx"); } else { LIdStatus.Text = result.Errors.FirstOrDefault(); } } catch (Exception ex) { LIdStatus.Text = ex.ToString(); } } else { LIdStatus.Text = "Lozinka mora biti ista"; } txtUserName.Text = string.Empty; }
protected void Button1_Click(object sender, EventArgs e) { UserStore <IdentityUser> userStore = new UserStore <IdentityUser>(); userStore.Context.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager. ConnectionStrings["db_1526927_1526927_co5025ConnectionString"].ConnectionString; UserManager <IdentityUser> manager = new UserManager <IdentityUser>(userStore); //register for new customer and information will be store in the DB IdentityUser user = new IdentityUser(); user.UserName = txtUserName.Text; if (txtPassword.Text == txtConfirmPassword.Text) { try { //user a create //database for user will be make IdentityResult result = manager.Create(user, txtPassword.Text); if (result.Succeeded) { UserInformation info = new UserInformation { Address = txtAddress.Text, FirstName = txtFirstName.Text, LastName = txtLastName.Text, PostalCode = Convert.ToInt32(txtPostalCode.Text), GUID = user.Id }; UserInfoModel model = new UserInfoModel(); model.InsertUserInformation(info); //user info will be store in DB var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; //new user login var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); //after login and it will birng the user to the homepage authenticationManager.SignIn(new Microsoft.Owin.Security.AuthenticationProperties(), userIdentity); Response.Redirect("~/Default.aspx"); } else { litStatus.Text = result.Errors.FirstOrDefault(); } } catch (Exception ex) { litStatus.Text = ex.ToString(); } } else { litStatus.Text = "The password must be same"; } }
protected void Button1_Click(object sender, EventArgs e) { // API to create user UserStore <IdentityUser> userStore = new UserStore <IdentityUser>(); userStore.Context.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WatchDBv2ConnectionString"].ConnectionString; UserManager <IdentityUser> manager = new UserManager <IdentityUser>(userStore); // Creating the user IdentityUser user = new IdentityUser(); user.UserName = txtUsrName.Text; if (txtPassword.Text == txtConfirmPassword.Text) { try { IdentityResult result = manager.Create(user, txtPassword.Text); if (result.Succeeded) { UserInformation info = new UserInformation { Address = txtAddress.Text, FirstName = txtFirstName.Text, LastName = txtLastName.Text, GUID = user.Id }; UserInfoModel model = new UserInfoModel(); model.InsertUserInformation(info); // Store in DB var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; // Set to log in by Cookie var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); litStatus.Text = "Registration successful!"; // Redirect to home page authenticationManager.SignIn(new AuthenticationProperties(), userIdentity); Response.Redirect("~/Pages/Index.aspx"); } else { litStatus.Text = result.Errors.FirstOrDefault(); } } catch (Exception ex) { litStatus.Text = ex.Message; } } else { litStatus.Text = "Passwords do not match"; } }