Example #1
0
        public string UserLogin(string userName, bool isAutoLogin)
        {
            if (string.IsNullOrEmpty(userName))
            {
                return(null);
            }

            var userInfo = UserManager.GetUserInfoByUserName(userName);

            if (userInfo == null || userInfo.IsLockedOut || !userInfo.IsChecked)
            {
                return(null);
            }

            UserInfo = userInfo;

            var expiresAt   = DateTime.Now.AddDays(AccessTokenExpireDays);
            var accessToken = GetAccessToken(UserId, UserName, expiresAt);

            DataProvider.UserDao.UpdateLastActivityDateAndCountOfLogin(UserInfo);
            LogUtils.AddUserLoginLog(userName);

            if (isAutoLogin)
            {
                CookieUtils.SetCookie(AuthKeyUserCookie, accessToken, expiresAt);
            }
            else
            {
                CookieUtils.SetCookie(AuthKeyUserCookie, accessToken);
            }

            return(accessToken);
        }
Example #2
0
        public void UserLogin(string userName)
        {
            if (string.IsNullOrEmpty(userName))
            {
                return;
            }

            UserName = userName;
            LogUtils.AddUserLoginLog(userName);
            CookieUtils.SetCookie(UserAccessToken, GetUserTokenByUserName(userName), DateTime.Now.AddDays(AccessTokenExpireDays));
        }
Example #3
0
        public string UserLogin(string userName)
        {
            if (string.IsNullOrEmpty(userName))
            {
                return(null);
            }

            UserName = userName;

            var accessToken = GetUserTokenByUserName(userName);

            LogUtils.AddUserLoginLog(userName);
            CookieUtils.SetCookie(AuthKeyUserCookie, accessToken, DateTime.Now.AddDays(AccessTokenExpireDays));

            return(accessToken);
        }