protected void btnLogin_Click(object sender, EventArgs e) { var email = txtEmail.Text; var password = txtPassword.Text; var admin = _userManager.AdminLoginWithEmail(email); if (admin != null) { if (admin.Email == email || admin.Password == password) { if (admin.Name == "Admin") { Session.Add("UserName", $"{admin.UserName}"); Session.Add("Id", $"{admin.Id}"); EnteranceLog enterance = new EnteranceLog(); _enteranceLogManager.Add(enterance); if (checkRemember.Checked) { Response.Cookies["Email"].Value = txtEmail.Text; Response.Cookies["Email"].Expires = DateTime.Now.AddHours(1); } Response.Redirect("~/Administrator/AdminPage.aspx"); } } } }
protected void btnSıgnIn_Click(object sender, EventArgs e) { var userName = txtUserName.Text; var email = txtEmail.Text; var password = txtPassword.Text; var login = _userManager.UserLogin(email); var DePassword = _userManager.Decrypt(login.Password); if (login != null) { if (login.UserName == userName || DePassword == password) { Session.Add("UserName", $"{login.UserName}"); Session.Add("Id", $"{login.Id}"); EnteranceLog enteranceLog = new EnteranceLog(); _logManager.Add(enteranceLog); if (checkRemember.Checked) { Response.Cookies["UserName"].Value = txtUserName.Text; Response.Cookies["Email"].Value = txtEmail.Text; Response.Cookies["UserName"].Expires = DateTime.Now.AddHours(12); Response.Cookies["Email"].Expires = DateTime.Now.AddHours(12); } Response.Redirect("~/WebSite/SinemaDevi.Home.aspx"); } } }
public void Add(EnteranceLog enteranceLog) { User user = _context.Users.FirstOrDefault(); enteranceLog.UserId = Convert.ToInt32(HttpContext.Current.Session["Id"]); enteranceLog.EnteranceDate = DateTime.Now; enteranceLog.IpAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; _enteranceLogDal.Add(enteranceLog); }