Пример #1
0
        public string GetToken()
        {
            if (Authenticated)
            {
                return(SecureToken.CreateToken(this.UserID));
            }

            return("");
        }
Пример #2
0
        public bool Authenticate(string token)
        {
            SecureToken sToken = new SecureToken(token);

            if (sToken.Valid)
            {
                Authenticated = KeyLoad(sToken.UserId);
                if (Authenticated)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
        public bool New(string userid, string password)
        {
            if (this.Load(userid))
            {
                return(false);
            }

            if (this.InitNew())
            {
                this.UserID   = userid;
                this.Password = SecureToken.Encrypt(password);
                return(true);
            }


            return(false);
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["login"];

            if (cookie != null)
            {
                User u = new User();
                if (u.Authenticate(cookie.Value))
                {
                    CurrentUser = u;
                    Response.SetCookie(new HttpCookie("login", SecureToken.CreateToken(u.UserID))
                    {
                        Expires = new DateTime(2100, 1, 1)
                    });
                }
            }

            PreInitPage();
        }
Пример #5
0
 public bool LogIn(string password)
 {
     Authenticated = SecureToken.Encrypt(password) == Password;
     return(Authenticated);
 }