/// <summary>
        /// 保存用户信息
        /// </summary>
        /// <param name="user">用户</param>
        protected override void SaveUserInfo(UserT user)
        {
            var claims   = IdentityAuthUtil.SaveUserInfoGetClaims(user, authUserData);
            var identity = new ClaimsIdentity(claims, GetAuthenticationScheme());

            SignIn(new ClaimsPrincipal(identity));
        }
Ejemplo 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);
        }