Exemple #1
0
        public Task ValidateAsync(ExtensionGrantValidationContext context)
        {
            var phone = context.Request.Raw["phone"];
            var code  = context.Request.Raw["auth_code"];

            if (_userStore.CheckVerificationCode(phone, code))
            {
                var userId = _userStore.CheckPhoneOrEmailAdd(phone);
                if (!string.IsNullOrEmpty(userId))
                {
                    context.Result = new GrantValidationResult(userId, "sms");
                    return(Task.CompletedTask);
                }
                else
                {
                    context.Result = new GrantValidationResult(TokenRequestErrors.InvalidClient, "添加用户失败");
                    return(Task.CompletedTask);
                }
            }
            context.Result = new GrantValidationResult(TokenRequestErrors.InvalidClient, "验证码不正确");
            return(Task.CompletedTask);
        }