コード例 #1
0
        public async Task <IActionResult> Create(AuthenticationViewModel model)
        {
            if (ModelState.IsValid)
            {
                OAuthOptions oAuthOptions;
                if (HandlerHelper.GetProviderName(model.HandlerType) == "Google")
                {
                    oAuthOptions = new GoogleOptions();
                }
                else
                {
                    oAuthOptions = new OAuthOptions();
                }

                oAuthOptions.ClientId     = model.ClientId;
                oAuthOptions.ClientSecret = model.ClientSecret;
                oAuthOptions.CallbackPath = "/signin-" + model.Scheme;

                await _manager.AddAsync(new SchemeDefinition
                {
                    Scheme      = model.Scheme,
                    DisplayName = model.DisplayName,
                    HandlerType = _manager.ManagedHandlerType.First(t => t.Name == model.HandlerType),
                    Options     = oAuthOptions
                });

                return(RedirectToAction("List"));
            }

            return(View(model));
        }