示例#1
0
        /// <summary>
        /// 登入
        /// </summary>
        /// <param name="uid">ID</param>
        /// <param name="pwd">密码</param>
        /// <returns>访问令牌</returns>
        public static String login(String uid, String pwd)
        {
            UserInfoModel user = getUserInfo(uid);

            if (user != null)
            {
                if (!user.authPwd(pwd))
                {
                    return(String.Empty);
                }
                String token = String.Empty;
                if (user.tokenIsNull())
                {
                    String str = generateToken(uid);
                    return(str);
                }
                else
                {
                    if ((DateTime.Now - user.getTokenGenerateTime()).TotalDays > 7)
                    {
                        return(generateToken(uid));
                    }
                    return(user.getToken(pwd));
                }
            }
            else
            {
                return(String.Empty);
            }
        }