public JavaScriptResult Control(AdminInformationTable adminInformation) { _loginCore.Log(adminInformation.AdminName, adminInformation.AdminPassword); if (_loginCore.Status == true) { const int userId = 1; const string role = "Admin"; string userData = userId.ToString(CultureInfo.InvariantCulture) + "," + adminInformation.AdminName.Trim() + "," + role; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, adminInformation.AdminName, DateTime.Now, DateTime.Now.AddMinutes(120), false, userData, FormsAuthentication.FormsCookiePath); string encryptedTicket = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); cookie.HttpOnly = true; Response.Cookies.Add(cookie); string s = "$('#divError').html('<img src=/Areas/Administrator/Images/ajax-loader.gif class=loaderGif></img>'); window.location='/administrator/newarticles'"; return(JavaScript(s)); } else { string rtrn = "$('#divError').html('Hatalı Kullanıcı Adı veya şifre');"; return(JavaScript(rtrn)); } }
public void Log(string userName, string userPassword) { try { AdminInformationTable adminTable = (from p in _FashionSiteContext.Admin select p).First(); if (userName == adminTable.AdminName && userPassword == adminTable.AdminPassword) { Status = true; } else { Status = false; } } catch (Exception) { _adminInformationTable.AdminName = "site"; _adminInformationTable.AdminPassword = "******"; using (FashionSiteContext db = new FashionSiteContext()) { db.Admin.Add(_adminInformationTable); db.SaveChanges(); } _adminInformationTable = (from p in _FashionSiteContext.Admin select p).First(); if (userName == _adminInformationTable.AdminName && userPassword == _adminInformationTable.AdminPassword) { Status = true; } else { Status = false; } } }
public ModelUser() { _contactTable = new ContactsTable(); _adminContext = new FashionSiteContext(); _adminTable = new AdminInformationTable(); }
public LoginCore() { _adminInformationTable = new AdminInformationTable(); _FashionSiteContext = new FashionSiteContext(); }