public ActionResult LoginControl(LoginParamDto model) { if (Accesses.IsLogin() != ForbiddenAccessTypes.UnForbidden || Accesses.IsLogin() == ForbiddenAccessTypes.IsLogout) { var person = _personService.GetPerson(model.UserName, model.Password); if (person == null) { return(AjaxMessage("Uyarı", "Yanlış kullanıcı adı veya şifre", MessageTypes.danger)); } if (person.IsActive) { } else { return(AjaxMessage("Uyarı", "Girş İzniniz Yoktur", MessageTypes.danger)); } var ticket = new FormsAuthenticationTicket(1, EnDeCode.Encrypt(person.Id.ToString(), StaticParams.SifrelemeParametresi), DateTime.Now, model.RememberMe ? DateTime.Now.AddYears(1) : DateTime.Now.AddDays(1), model.RememberMe, EnDeCode.Encrypt(person.Id.ToString(), StaticParams.SifrelemeParametresi), FormsAuthentication.FormsCookiePath); string encTicket = FormsAuthentication.Encrypt(ticket); var cookie = new HttpCookie(".u", encTicket); var personInitials = new HttpCookie("_initials", UtilityManager.Base64Encode(person.Initials)); var personFullName = new HttpCookie("_fullname", UtilityManager.Base64Encode(person.Name + " " + person.Surname)); var personEmail = new HttpCookie("_email", UtilityManager.Base64Encode(person.Email)); var unitId = new HttpCookie("_ui", UtilityManager.Base64Encode(person.UnitId.ToString())); cookie.HttpOnly = true; personInitials.HttpOnly = true; personFullName.HttpOnly = true; personEmail.HttpOnly = true; unitId.HttpOnly = true; cookie.Expires = model.RememberMe ? DateTime.Now.AddYears(1) : DateTime.Now.AddDays(1); personInitials.Expires = model.RememberMe ? DateTime.Now.AddYears(1) : DateTime.Now.AddDays(1); personFullName.Expires = model.RememberMe ? DateTime.Now.AddYears(1) : DateTime.Now.AddDays(1); personEmail.Expires = model.RememberMe ? DateTime.Now.AddYears(1) : DateTime.Now.AddDays(1); unitId.Expires = model.RememberMe ? DateTime.Now.AddYears(1) : DateTime.Now.AddDays(1); Response.Cookies.Add(cookie); Response.Cookies.Add(personInitials); Response.Cookies.Add(personFullName); Response.Cookies.Add(personEmail); Response.Cookies.Add(unitId); return(Json("/Dashboard", JsonRequestBehavior.AllowGet)); } else { return(AjaxMessage(MessageTitleTypes.Uyari, "Yanlış kullanıcı adı veya şifre", MessageTypes.danger)); } }
protected void Kaydetbtn_Click(object sender, EventArgs e) { baglanti.ConnectionString = adres; baglanti.Open(); string sql = "insert into common.Person values (@UnitId,@UserName,@kisa, @Name,@Suname,@Password, @Email, 2332,@booll, null)"; SqlCommand cmd = new SqlCommand(sql, baglanti); cmd.Parameters.AddWithValue("@Name", adi.Value); cmd.Parameters.AddWithValue("@Suname", soyadi.Value); cmd.Parameters.AddWithValue("@UserName", kullaniciAdi.Value); cmd.Parameters.AddWithValue("@Email", email.Value); cmd.Parameters.AddWithValue("@UnitId", unitlist.SelectedItem.Value); cmd.Parameters.AddWithValue("@Password", EnDeCode.Encrypt(sifre.Value, StaticParams.SifrelemeParametresi)); cmd.Parameters.AddWithValue("@booll", "False"); cmd.Parameters.AddWithValue("@kisa", adi.Value.Substring(0, 1).ToUpper() + soyadi.Value.Substring(0, 1).ToUpper()); cmd.ExecuteNonQuery(); baglanti.Close(); Response.Redirect("/Login/Index"); }