/// <summary>
 /// Deprecated Method for adding a new object to the RememberedSessions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRememberedSessions(RememberedSessions rememberedSessions)
 {
     base.AddObject("RememberedSessions", rememberedSessions);
 }
Example #2
0
        //Unsafe, stores guid directly in db, has same effect as storing password in cookie.
        public static void RememberLoggedInUser(HttpCookieCollection responseCookies)
        {
            using (var db = EpidaurusDbContainer.Create())
            {
                var user = LoggedInUser;
                string randGuid = Guid.NewGuid().ToString();

                string cookieValue = string.Format("{0}_{1}", user.Identity.Name, randGuid);
                var cookie = new HttpCookie(CookieName, cookieValue);
                cookie.Expires = DateTime.Now + TimeSpan.FromDays(100);
                cookie.Path = HttpContext.Current.Request.ApplicationPath;
                responseCookies.Add(cookie);

                var rs = new RememberedSessions()
                {
                    UserUsername = user.Identity.Name,
                    GuidHash = randGuid,
                    CreatedAt = DateTime.Now,
                };
                db.AddToRememberedSessions(rs);
                db.SaveChanges();
            }
        }
 /// <summary>
 /// Create a new RememberedSessions object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="userUsername">Initial value of the UserUsername property.</param>
 /// <param name="guidHash">Initial value of the GuidHash property.</param>
 /// <param name="createdAt">Initial value of the CreatedAt property.</param>
 public static RememberedSessions CreateRememberedSessions(global::System.Int32 id, global::System.String userUsername, global::System.String guidHash, global::System.DateTime createdAt)
 {
     RememberedSessions rememberedSessions = new RememberedSessions();
     rememberedSessions.Id = id;
     rememberedSessions.UserUsername = userUsername;
     rememberedSessions.GuidHash = guidHash;
     rememberedSessions.CreatedAt = createdAt;
     return rememberedSessions;
 }