public MainViewModel() { var(text, passage, url) = CookieGenerator.GenerateCookie(CookieType.Promises); Status = text; Passage = passage; PassageUrl = url; }
// Generate the cookie and put in database internal HttpCookie Cookie(string username) { var apiCookie = new HttpCookie("X-KEY") { Value = CookieGenerator.Create(username) }; using (var db = new SiteContext()) { Session curent; curent = db.Sessions.FirstOrDefault(u => u.Username == username); if (curent != null) { curent.CookieString = apiCookie.Value; curent.ExpireTime = DateTime.Now.AddDays(1); db.Entry(curent).State = EntityState.Modified; db.SaveChanges(); } else { db.Sessions.Add(new Session { Username = username, CookieString = apiCookie.Value, ExpireTime = DateTime.Now.AddDays(1) }); db.SaveChanges(); } } return(apiCookie); }
private AuthenticationViaFormAction(CredentialsBinder credentialsBinder, CentralAuthenticationService centralAuthenticationService, CookieGenerator warnCookieGenerator) { _credentialsBinder = credentialsBinder; _centralAuthenticationService = centralAuthenticationService; _warnCookieGenerator = warnCookieGenerator; }
public MainViewModel() { var(text, passage, url) = CookieGenerator.GenerateCookie(CookieType.Promises); Status = text; Passage = passage; PassageUrl = url; DeleteEmptyFolderViewModel = new DeleteEmptyFolderViewModel(this); }
protected override void Dispose(bool disposing) { if (!string.IsNullOrEmpty((string)TempData["CSEXC"])) { CookieGenerator.CreateNotificationCookie(NotificationTypeConstants.Danger, (string)TempData["CSEXC"]); TempData.Remove("CSEXC"); } if (disposing) { db.Dispose(); } base.Dispose(disposing); }
internal HttpCookie Cookie(string loginCredential) { var apiCookie = new HttpCookie("X-KEY") { Value = CookieGenerator.Create(loginCredential) }; using (var db = new SessionContext()) { Session curent; var validate = new EmailAddressAttribute(); if (validate.IsValid(loginCredential)) { curent = (from e in db.Sessions where e.Username == loginCredential select e).FirstOrDefault(); } else { curent = (from e in db.Sessions where e.Username == loginCredential select e).FirstOrDefault(); } if (curent != null) { curent.CookieString = apiCookie.Value; curent.ExpireTime = DateTime.Now.AddMinutes(60); using (var todo = new SessionContext()) { todo.Entry(curent).State = EntityState.Modified; todo.SaveChanges(); } } else { db.Sessions.Add(new Session { Username = loginCredential, CookieString = apiCookie.Value, ExpireTime = DateTime.Now.AddMinutes(60) }); db.SaveChanges(); } } return(apiCookie); }
public ActionResult Login(UserLogin login, string returnurl) { string message = " "; message = DBOperations.ReturnLoginAttemptresult(login, out Employee user); if (string.Compare(message, "Successful") == 0) { Response.Cookies.Add(CookieGenerator.LoginCookie(user, login)); if (Url.IsLocalUrl("")) { ViewBag.Message = "Something went wrong!"; return(Redirect("")); } else { return(RedirectToAction("Welcome", "Feed")); } } else { ViewBag.Message = message; } return(View()); }
public AuthenticationViaFormAction(CentralAuthenticationService centralAuthenticationService, CookieGenerator warnCookieGenerator) : this(null, centralAuthenticationService, warnCookieGenerator) { }