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));
        }
        public IActionResult Login(string returnUrl = null)
        {
            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);
        }
Beispiel #3
0
        public IActionResult Login(string returnUrl)
        {
            ViewData["Title"]     = "Log in";
            ViewData["ReturnUrl"] = returnUrl;
            LoginViewModel model = new LoginViewModel();

            model.ExternalAuthenticationList = signInManager.GetExternalAuthenticationSchemes();
            if ((Site.CaptchaOnLogin) && (Site.RecaptchaPublicKey.Length > 0))
            {
                model.RecaptchaSiteKey = Site.RecaptchaPublicKey;
            }

            model.LoginInfoTop    = Site.LoginInfoTop;
            model.LoginInfoBottom = Site.LoginInfoBottom;

            return(View(model));
        }
Beispiel #4
0
        public async Task <IActionResult> ManageLogins()
        {
            var user = await userManager.FindByIdAsync(HttpContext.User.GetUserId());

            if (user == null)
            {
                return(View("Error"));
            }
            var userLogins = await userManager.GetLoginsAsync(user);

            var otherLogins = signInManager.GetExternalAuthenticationSchemes().Where(auth => userLogins.All(ul => auth.AuthenticationScheme != ul.LoginProvider)).ToList();

            ViewBag.ShowRemoveButton = user.PasswordHash != null || userLogins.Count > 1;
            return(View(new ManageLoginsViewModel
            {
                CurrentLogins = userLogins,
                OtherLogins = otherLogins
            }));
        }
Beispiel #5
0
 public IEnumerable <AuthenticationDescription> GetExternalAuthenticationSchemes()
 {
     return(signInManager.GetExternalAuthenticationSchemes().OrderBy(x => x.DisplayName));
 }