コード例 #1
0
        public async Task <IActionResult> Index(string returnUrl)
        {
            returnUrl = identityServerIntegration.EnsureFolderSegmentIfNeeded(_site, returnUrl);
            var vm = await BuildViewModelAsync(returnUrl);

            if (vm != null)
            {
                return(View("Index", vm));
            }

            return(View("Error"));
        }
コード例 #2
0
        public async Task <IActionResult> Login(string returnUrl = null)
        {
            if (signInManager.IsSignedIn(User))
            {
                return(this.RedirectToSiteRoot(Site));
            }

            returnUrl = identityServerIntegration.EnsureFolderSegmentIfNeeded(Site, returnUrl);
            //identityserver integration point
            var idProvider = await identityServerIntegration.GetAuthorizationContextAsync(returnUrl);

            if (!string.IsNullOrEmpty(idProvider))
            {
                // if IdP is passed, then bypass showing the login screen
                return(ExternalLogin(idProvider, returnUrl));
            }

            ViewData["Title"]     = sr["Log in"];
            ViewData["ReturnUrl"] = returnUrl;
            LoginViewModel model = new LoginViewModel();

            if ((Site.CaptchaOnLogin) && (Site.RecaptchaPublicKey.Length > 0))
            {
                model.RecaptchaSiteKey = Site.RecaptchaPublicKey;
            }
            model.UseEmailForLogin           = Site.UseEmailForLogin;
            model.LoginInfoTop               = Site.LoginInfoTop;
            model.LoginInfoBottom            = Site.LoginInfoBottom;
            model.ExternalAuthenticationList = signInManager.GetExternalAuthenticationSchemes();
            // don't disable db auth if there are no social auth providers configured
            model.DisableDbAuth = Site.DisableDbAuth && Site.HasAnySocialAuthEnabled();

            return(View(model));
        }
コード例 #3
0
        public async Task <IActionResult> Login(string returnUrl = null)
        {
            if (_accountService.IsSignedIn(User))
            {
                return(this.RedirectToSiteRoot(_currentSite));
            }

            returnUrl = _identityServerIntegration.EnsureFolderSegmentIfNeeded(_currentSite, returnUrl);
            //identityserver integration point
            var idProvider = await _identityServerIntegration.GetAuthorizationContextAsync(returnUrl);

            if (!string.IsNullOrEmpty(idProvider))
            {
                // if IdP is passed, then bypass showing the login screen
                return(ExternalLogin(idProvider, returnUrl));
            }

            ViewData["Title"]     = _sr["Log In"];
            ViewData["ReturnUrl"] = returnUrl;

            var model = new LoginViewModel();

            var recaptchaKeys = await _recaptchaKeysProvider.GetKeys().ConfigureAwait(false);

            if ((_currentSite.CaptchaOnLogin) && (!string.IsNullOrEmpty(recaptchaKeys.PublicKey)))
            {
                model.RecaptchaSiteKey    = recaptchaKeys.PublicKey;
                model.UseInvisibleCaptcha = recaptchaKeys.Invisible;
            }
            model.UseEmailForLogin = _currentSite.UseEmailForLogin;
            model.LoginInfoTop     = _currentSite.LoginInfoTop;
            model.LoginInfoBottom  = _currentSite.LoginInfoBottom;
            var externalSchemes = await _accountService.GetExternalAuthenticationSchemes();

            model.ExternalAuthenticationList = externalSchemes.ToList();
            // don't disable db auth if there are no social auth providers configured
            model.DisableDbAuth = _currentSite.DisableDbAuth && _currentSite.HasAnySocialAuthEnabled();

            return(View(model));
        }