public async Task <IActionResult> Register(string returnUrl = null) { if (_accountService.IsSignedIn(User)) { return(this.RedirectToSiteRoot(_currentSite)); } if (!_currentSite.AllowNewRegistration) { return(new StatusCodeResult(404)); } // login is equivalent to register for new social auth users // if db auth is disabled just redirect if (_currentSite.DisableDbAuth && _currentSite.HasAnySocialAuthEnabled()) { return(RedirectToAction("Login")); } ViewData["Title"] = _sr["Register"]; 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["ReturnUrl"] = returnUrl; var model = new RegisterViewModel { SiteId = _currentSite.Id }; if ((_currentSite.CaptchaOnRegistration) && (!string.IsNullOrWhiteSpace(_currentSite.RecaptchaPublicKey))) { model.RecaptchaSiteKey = _currentSite.RecaptchaPublicKey; model.UseInvisibleCaptcha = _currentSite.UseInvisibleRecaptcha; } model.UseEmailForLogin = _currentSite.UseEmailForLogin; model.RegistrationPreamble = _currentSite.RegistrationPreamble; model.RegistrationAgreement = _currentSite.RegistrationAgreement; model.AgreementRequired = !string.IsNullOrWhiteSpace(_currentSite.RegistrationAgreement); model.ExternalAuthenticationList = await _accountService.GetExternalAuthenticationSchemes(); var viewName = await _customRegistration.GetRegisterViewName(_currentSite, HttpContext); await _customRegistration.HandleRegisterGet( _currentSite, model, HttpContext, ViewData); return(View(viewName, model)); }
public async Task <IActionResult> Register(string returnUrl = null) { if (accountService.IsSignedIn(User)) { return(this.RedirectToSiteRoot(Site)); } if (!Site.AllowNewRegistration) { return(new StatusCodeResult(404)); } // login is equivalent to register for new social auth users // if db auth is disabled just redirect if (Site.DisableDbAuth && Site.HasAnySocialAuthEnabled()) { return(RedirectToAction("Login")); } ViewData["Title"] = sr["Register"]; var model = new RegisterViewModel(); model.SiteId = Site.Id; if ((Site.CaptchaOnRegistration) && (Site.RecaptchaPublicKey.Length > 0)) { model.RecaptchaSiteKey = Site.RecaptchaPublicKey; model.UseInvisibleCaptcha = Site.UseInvisibleRecaptcha; } model.UseEmailForLogin = Site.UseEmailForLogin; model.RegistrationPreamble = Site.RegistrationPreamble; model.RegistrationAgreement = Site.RegistrationAgreement; model.AgreementRequired = Site.RegistrationAgreement.Length > 0; model.ExternalAuthenticationList = accountService.GetExternalAuthenticationSchemes(); var viewName = await customRegistration.GetRegisterViewName(Site, HttpContext); await customRegistration.HandleRegisterGet( Site, model, HttpContext, ViewData); return(View(viewName, model)); }