/// <summary>
        /// 授权
        /// </summary>
        /// <param name="user">用户</param>
        /// <param name="password">密码</param>
        /// <returns>返回信息</returns>
        public ReturnInfo <UserT> Accredit(string user, string password)
        {
            if (userVali == null)
            {
                throw new NullReferenceException("用户验证不能为null");
            }

            ReturnInfo <UserT> returnInfo = userVali.Vali(user, password);

            if (returnInfo.Failure())
            {
                return(returnInfo);
            }

            SaveUserInfo(returnInfo.Data);

            return(returnInfo);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 授权并生成令牌
        /// </summary>
        /// <param name="user">用户</param>
        /// <param name="password">密码</param>
        /// <param name="comData">通用数据</param>
        /// <returns>返回信息</returns>
        public ReturnInfo <string> AccreditToToken(string user, string password, CommonUseData comData = null)
        {
            if (userVali == null)
            {
                throw new NullReferenceException("用户验证不能为null");
            }

            var re = new ReturnInfo <string>();
            ReturnInfo <UserT> returnInfo = userVali.Vali(user, password, comData);

            re.FromBasic(returnInfo);
            if (re.Failure())
            {
                return(re);
            }

            var claims = IdentityAuthUtil.SaveUserInfoGetClaims(returnInfo.Data, authUserData);

            re.Data = BuilderToken(claims);

            return(re);
        }