use the official discord button on registration page as well
and disable the not yet approved external login providers on the registration page
This commit is contained in:
@@ -116,6 +116,12 @@ namespace Kemkas.Web.Areas.Identity.Pages.Account
|
|||||||
|
|
||||||
ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
|
ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
|
||||||
|
|
||||||
|
// Disable not yet approved external login providers in production
|
||||||
|
if (!_environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
ExternalLogins = ExternalLogins.Where(el => el.Name == "Discord").ToList();
|
||||||
|
}
|
||||||
|
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
// This doesn't count login failures towards account lockout
|
// This doesn't count login failures towards account lockout
|
||||||
|
|||||||
@@ -49,7 +49,8 @@
|
|||||||
<form id="external-account" asp-page="./ExternalLogin" asp-route-returnUrl="@Model.ReturnUrl" method="post" class="form-horizontal">
|
<form id="external-account" asp-page="./ExternalLogin" asp-route-returnUrl="@Model.ReturnUrl" method="post" class="form-horizontal">
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<p>
|
||||||
@foreach (var provider in Model.ExternalLogins!)
|
<button type="submit" class="btn" name="provider" value="Discord" title="Log in using your Discord account"><img height="24px" alt="Discord" src="/img/discord-logo-blue.svg" /></button>
|
||||||
|
@foreach (var provider in Model.ExternalLogins!.Where(el => el.Name != "Discord"))
|
||||||
{
|
{
|
||||||
<button type="submit" class="btn btn-primary" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
|
<button type="submit" class="btn btn-primary" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,13 +30,15 @@ namespace Kemkas.Web.Areas.Identity.Pages.Account
|
|||||||
private readonly IUserEmailStore<ApplicationUser> _emailStore;
|
private readonly IUserEmailStore<ApplicationUser> _emailStore;
|
||||||
private readonly ILogger<RegisterModel> _logger;
|
private readonly ILogger<RegisterModel> _logger;
|
||||||
private readonly IEmailSender _emailSender;
|
private readonly IEmailSender _emailSender;
|
||||||
|
private readonly IWebHostEnvironment _environment;
|
||||||
|
|
||||||
public RegisterModel(
|
public RegisterModel(
|
||||||
UserManager<ApplicationUser> userManager,
|
UserManager<ApplicationUser> userManager,
|
||||||
IUserStore<ApplicationUser> userStore,
|
IUserStore<ApplicationUser> userStore,
|
||||||
SignInManager<ApplicationUser> signInManager,
|
SignInManager<ApplicationUser> signInManager,
|
||||||
ILogger<RegisterModel> logger,
|
ILogger<RegisterModel> logger,
|
||||||
IEmailSender emailSender)
|
IEmailSender emailSender,
|
||||||
|
IWebHostEnvironment environment)
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_userStore = userStore;
|
_userStore = userStore;
|
||||||
@@ -44,6 +46,7 @@ namespace Kemkas.Web.Areas.Identity.Pages.Account
|
|||||||
_signInManager = signInManager;
|
_signInManager = signInManager;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_emailSender = emailSender;
|
_emailSender = emailSender;
|
||||||
|
_environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -105,12 +108,22 @@ namespace Kemkas.Web.Areas.Identity.Pages.Account
|
|||||||
{
|
{
|
||||||
ReturnUrl = returnUrl;
|
ReturnUrl = returnUrl;
|
||||||
ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
|
ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
|
||||||
|
// Disable not yet approved external login providers in production
|
||||||
|
if (!_environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
ExternalLogins = ExternalLogins.Where(el => el.Name == "Discord").ToList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> OnPostAsync(string returnUrl = null)
|
public async Task<IActionResult> OnPostAsync(string returnUrl = null)
|
||||||
{
|
{
|
||||||
returnUrl ??= Url.Content("~/");
|
returnUrl ??= Url.Content("~/");
|
||||||
ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
|
ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
|
||||||
|
// Disable not yet approved external login providers in production
|
||||||
|
if (!_environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
ExternalLogins = ExternalLogins.Where(el => el.Name == "Discord").ToList();
|
||||||
|
}
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
{
|
{
|
||||||
return Page();
|
return Page();
|
||||||
|
|||||||
Reference in New Issue
Block a user