Skip to content

Commit

Permalink
use official discord button and disable other not yet approved extern…
Browse files Browse the repository at this point in the history
…al login providers
  • Loading branch information
morbalint committed Jan 21, 2024
1 parent 55eeae5 commit fb89640
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
<form id="external-account" asp-page="./ExternalLogin" asp-route-returnUrl="@Model.ReturnUrl" method="post" class="form-horizontal">
<div>
<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>
}
Expand Down
10 changes: 9 additions & 1 deletion Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ public class LoginModel : PageModel
{
private readonly SignInManager<ApplicationUser> _signInManager;
private readonly ILogger<LoginModel> _logger;
private readonly IWebHostEnvironment _environment;

public LoginModel(SignInManager<ApplicationUser> signInManager, ILogger<LoginModel> logger)
public LoginModel(SignInManager<ApplicationUser> signInManager, ILogger<LoginModel> logger, IWebHostEnvironment environment)
{
_signInManager = signInManager;
_logger = logger;
_environment = environment;
}

/// <summary>
Expand Down Expand Up @@ -98,6 +100,12 @@ public async Task OnGetAsync(string returnUrl = null)
await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);

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();
}

ReturnUrl = returnUrl;
}
Expand Down
4 changes: 4 additions & 0 deletions Kemkas.Web/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,9 @@ http {
proxy_pass https://backend;
proxy_pass_request_headers on;
}
location /img/ {
proxy_pass https://backend;
proxy_pass_request_headers on;
}
}
}
1 change: 1 addition & 0 deletions Kemkas.Web/wwwroot/img/discord-logo-blue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fb89640

Please sign in to comment.