コード例 #1
0
        public IActionResult Index(
            string type,
            [FromServices] BaiduOAuth baiduOAuth,
            [FromServices] WechatOAuth wechatOAuth,
            [FromServices] GitlabOAuth gitlabOAuth,
            [FromServices] GiteeOAuth giteeOAuth,
            [FromServices] GithubOAuth githubOAuth,
            [FromServices] HuaweiOAuth huaweiOAuth,
            [FromServices] CodingOAuth codingOAuth,
            [FromServices] SinaWeiboOAuth sinaWeiboOAuth,
            [FromServices] AlipayOAuth alipayOAuth,
            [FromServices] QQOAuth qqOAuth,
            [FromServices] OSChinaOAuth oschinaOAuth,
            [FromServices] DouYinOAuth douYinOAuth,
            [FromServices] WechatOpenOAuth wechatOpenOAuth,
            [FromServices] MeiTuanOAuth meiTuanOAuth,
            [FromServices] XunLeiOAuth xunLeiOAuth
            )
        {
            var redirectUrl = "";
            var state       = DefaultStateManager.Instance().RequestState();

            switch (type.ToLower())
            {
            case "baidu":
            {
                redirectUrl = baiduOAuth.GetAuthorizeUrl(state);
                break;
            }

            case "wechat":
            {
                redirectUrl = wechatOAuth.GetAuthorizeUrl(state);
                break;
            }

            case "gitlab":
            {
                redirectUrl = gitlabOAuth.GetAuthorizeUrl(state);
                break;
            }

            case "gitee":
            {
                redirectUrl = giteeOAuth.GetAuthorizeUrl(state);
                break;
            }

            case "github":
            {
                redirectUrl = githubOAuth.GetAuthorizeUrl(state);
                break;
            }

            case "huawei":
            {
                redirectUrl = huaweiOAuth.GetAuthorizeUrl(state);
                break;
            }

            case "coding":
            {
                redirectUrl = codingOAuth.GetAuthorizeUrl(state);
                break;
            }

            case "sinaweibo":
            {
                redirectUrl = sinaWeiboOAuth.GetAuthorizeUrl(state);
                break;
            }

            case "alipay":
            {
                redirectUrl = alipayOAuth.GetAuthorizeUrl(state);
                break;
            }

            case "qq":
            {
                redirectUrl = qqOAuth.GetAuthorizeUrl(state);
                break;
            }

            case "oschina":
            {
                redirectUrl = oschinaOAuth.GetAuthorizeUrl(state);
                break;
            }

            case "douyin":
            {
                redirectUrl = douYinOAuth.GetAuthorizeUrl(state);
                break;
            }

            case "wechatopen":
            {
                redirectUrl = wechatOpenOAuth.GetAuthorizeUrl(state);
                break;
            }

            case "meituan":
            {
                redirectUrl = meiTuanOAuth.GetAuthorizeUrl(state);
                break;
            }

            case "xunlei":
            {
                redirectUrl = xunLeiOAuth.GetAuthorizeUrl(state);
                break;
            }

            default:
                return(ReturnToError($"没有实现【{type}】登录方式!"));
            }
            return(Redirect(redirectUrl));
        }