Here is the code for login page
namespace Eduverse.Pages.Account
{
[DisableAuditing]
public class LoginModel : AccountPageModel
{
[HiddenInput]
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; }
[HiddenInput]
[BindProperty(SupportsGet = true)]
public string ReturnUrlHash { get; set; }
[HiddenInput]
[BindProperty(SupportsGet = true)]
public Guid? LinkUserId { get; set; }
[HiddenInput]
[BindProperty(SupportsGet = true)]
public Guid? LinkTenantId { get; set; }
[HiddenInput]
[BindProperty(SupportsGet = true)]
public string LinkToken { get; set; }
public bool IsLinkLogin { get; set; }
[BindProperty]
public LoginInputModel LoginInput { get; set; }
public bool EnableLocalLogin { get; set; }
public bool IsSelfRegistrationEnabled { get; set; }
public bool ShowCancelButton { get; set; }
public bool UseCaptcha { get; set; }
//TODO: Why there is an ExternalProviders if only the VisibleExternalProviders is used.
public IEnumerable<ExternalProviderModel> ExternalProviders { get; set; }
public IEnumerable<ExternalProviderModel> VisibleExternalProviders => ExternalProviders.Where(x => !string.IsNullOrWhiteSpace(x.DisplayName));
public bool IsExternalLoginOnly => EnableLocalLogin == false && ExternalProviders?.Count() == 1;
public string ExternalLoginScheme => IsExternalLoginOnly ? ExternalProviders?.SingleOrDefault()?.AuthenticationScheme : null;
protected readonly IAuthenticationSchemeProvider SchemeProvider;
protected readonly AbpAccountOptions AccountOptions;
protected readonly ICurrentPrincipalAccessor CurrentPrincipalAccessor;
protected readonly IAbpRecaptchaValidatorFactory RecaptchaValidatorFactory;
protected readonly IAccountExternalProviderAppService AccountExternalProviderAppService;
public LoginModel(
IAuthenticationSchemeProvider schemeProvider,
IOptions<AbpAccountOptions> accountOptions,
IAbpRecaptchaValidatorFactory recaptchaValidatorFactory,
IAccountExternalProviderAppService accountExternalProviderAppService,
ICurrentPrincipalAccessor currentPrincipalAccessor,
IOptions<IdentityOptions> identityOptions,
IOptionsSnapshot<reCAPTCHAOptions> reCaptchaOptions)
{
SchemeProvider = schemeProvider;
AccountExternalProviderAppService = accountExternalProviderAppService;
AccountOptions = accountOptions.Value;
CurrentPrincipalAccessor = currentPrincipalAccessor;
RecaptchaValidatorFactory = recaptchaValidatorFactory;
}
public virtual async Task<IActionResult> OnGetAsync()
{
LoginInput = new LoginInputModel();
var localLoginResult = await CheckLocalLoginAsync();
if (localLoginResult != null)
{
return localLoginResult;
}
IsSelfRegistrationEnabled = await SettingProvider.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled);
UseCaptcha = await UseCaptchaOnLoginAsync();
IsLinkLogin = await VerifyLinkTokenAsync();
if (IsLinkLogin)
{
if (CurrentUser.IsAuthenticated)
{
await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext
{
Identity = IdentitySecurityLogIdentityConsts.Identity,
Action = IdentitySecurityLogActionConsts.Logout
});
await SignInManager.SignOutAsync();
return Redirect(HttpContext.Request.GetDisplayUrl());
}
}
return Page();
}
etc...
}
}
Hi,
Nope we are using a project with combined auth server (But we are using a layered application if that is applicable)
I'm trying to add that file in src\Eduverse.HttpApi.Host\Pages\Account\Register.cshtml.cs
however it does not seem to work. Am I missing anything for the override?
Hi,
Okay, we are thinking of overriding the Register screen (the snippet you highlighted) and don't do the redirect to /ChangePassword for external logins.
This also means that external users would not have any password set. Is that any risk? we want external users only to have to login using the SSO flow and never using password.
Hi,
Actually we do NOT want to show the password reset screen what is the simplest way we can implement this change? thanks
let me try and get back to you