Inheritance: MonoBehaviour
Beispiel #1
0
 public MainViewModel()
 {
     var(text, passage, url) = CookieGenerator.GenerateCookie(CookieType.Promises);
     Status     = text;
     Passage    = passage;
     PassageUrl = url;
 }
Beispiel #2
0
        // 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);
        }
Beispiel #3
0
 private AuthenticationViaFormAction(CredentialsBinder credentialsBinder,
                                     CentralAuthenticationService centralAuthenticationService,
                                     CookieGenerator warnCookieGenerator)
 {
     _credentialsBinder            = credentialsBinder;
     _centralAuthenticationService = centralAuthenticationService;
     _warnCookieGenerator          = warnCookieGenerator;
 }
Beispiel #4
0
 public MainViewModel()
 {
     var(text, passage, url) = CookieGenerator.GenerateCookie(CookieType.Promises);
     Status     = text;
     Passage    = passage;
     PassageUrl = url;
     DeleteEmptyFolderViewModel = new DeleteEmptyFolderViewModel(this);
 }
Beispiel #5
0
 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);
 }
Beispiel #6
0
        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());
        }
Beispiel #8
0
 public AuthenticationViaFormAction(CentralAuthenticationService centralAuthenticationService,
                                    CookieGenerator warnCookieGenerator)
     : this(null, centralAuthenticationService, warnCookieGenerator)
 {
 }