Exemplo n.º 1
0
        public static void Signout(HttpContext context)
        {
            T user = default(T);

            if (SigningOut != null || SignedOut != null)
            {
                user = (T)HttpContext.Current.Session["Burst.Web.UserBase.Current"];
            }
            if (SigningOut != null)
            {
                UserStatusEventArgs e = new UserStatusEventArgs(context, false);
                SigningOut(user, e);
                if (e.Cancel)
                {
                    return;
                }
            }
            HttpContext.Current.Session.Remove("Burst.Web.UserBase.Current");
            HttpCookie hc = context.Request.Cookies["SInfo"];

            if (hc != null)
            {
                hc.Expires = DateTime.Now.AddDays(-1);
                context.Response.Cookies.Add(hc);
            }
            if (SignedOut != null)
            {
                SignedOut(user, new UserStatusEventArgs(context, false));
            }
        }
Exemplo n.º 2
0
        public static void Signin(T user, DateTime?expires, HttpContext context)
        {
            if (SigningIn != null)
            {
                UserStatusEventArgs e = new UserStatusEventArgs(context, false);
                SigningIn(user, e);
                if (e.Cancel)
                {
                    return;
                }
            }
            (user as UserBase <T>).IP = WebUtils.GetClientIP(context);
            HttpCookie hc = new HttpCookie("SInfo");

            hc.Values.Add(".b", CryptUtils.EncryptDES((user as UserBase <T>).UserName));
            hc.Values.Add(".a", CryptUtils.EncryptDES((user as UserBase <T>).Password));
            if (expires != null)
            {
                hc.Values.Add(".c", expires.ToString());
                hc.Expires = (DateTime)expires;
            }
            context.Response.Cookies.Set(hc);
            context.Session["Burst.Web.UserBase.Current"] = user;
            if (SignedIn != null)
            {
                SignedIn(user, new UserStatusEventArgs(context, false));
            }
        }