Exemplo n.º 1
0
 public virtual void SignOut()
 {
     _cachedUser = null;
     FormsAuthentication.SignOut();
 }
Exemplo n.º 2
0
        public virtual void SignIn(user user, bool createPersistentCookie)
        {
            var now = DateTime.UtcNow.ToLocalTime();

            var ticket = new FormsAuthenticationTicket(
                1 /*version*/,
                user.userName,
                now,
                now.Add(_expirationTimeSpan),
                createPersistentCookie,
                user.userName,
                FormsAuthentication.FormsCookiePath);

            var encryptedTicket = FormsAuthentication.Encrypt(ticket);

            var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
            cookie.HttpOnly = true;
            if (ticket.IsPersistent)
            {
                cookie.Expires = ticket.Expiration;
            }
            cookie.Secure = FormsAuthentication.RequireSSL;
            cookie.Path = FormsAuthentication.FormsCookiePath;
            if (FormsAuthentication.CookieDomain != null)
            {
                cookie.Domain = FormsAuthentication.CookieDomain;
            }

            _httpContext.Response.Cookies.Add(cookie);
            _cachedUser = user;
        }
Exemplo n.º 3
0
 public bool Exist(user u1)
 {
     var count = _userRepository.Table.Count(u => u.userName == u1.userName
                                                  && u.password == u1.password);
     return count > 0;
 }