From fb8964062bfefa400c3cbca8114c85880c6fc457 Mon Sep 17 00:00:00 2001 From: morbalint Date: Sun, 21 Jan 2024 14:51:17 +0100 Subject: [PATCH] use official discord button and disable other not yet approved external login providers --- Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml | 3 ++- .../Areas/Identity/Pages/Account/Login.cshtml.cs | 10 +++++++++- Kemkas.Web/nginx.conf | 4 ++++ Kemkas.Web/wwwroot/img/discord-logo-blue.svg | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 Kemkas.Web/wwwroot/img/discord-logo-blue.svg diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml index 6354164..4631e8a 100644 --- a/Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml +++ b/Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml @@ -65,7 +65,8 @@

- @foreach (var provider in Model.ExternalLogins!) + + @foreach (var provider in Model.ExternalLogins!.Where(el => el.Name != "Discord")) { } diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml.cs index 3f3857d..dd52b3b 100644 --- a/Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml.cs +++ b/Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml.cs @@ -22,11 +22,13 @@ namespace Kemkas.Web.Areas.Identity.Pages.Account { private readonly SignInManager _signInManager; private readonly ILogger _logger; + private readonly IWebHostEnvironment _environment; - public LoginModel(SignInManager signInManager, ILogger logger) + public LoginModel(SignInManager signInManager, ILogger logger, IWebHostEnvironment environment) { _signInManager = signInManager; _logger = logger; + _environment = environment; } ///

@@ -98,6 +100,12 @@ namespace Kemkas.Web.Areas.Identity.Pages.Account 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; } diff --git a/Kemkas.Web/nginx.conf b/Kemkas.Web/nginx.conf index 62985e2..dba2cfe 100644 --- a/Kemkas.Web/nginx.conf +++ b/Kemkas.Web/nginx.conf @@ -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; + } } } diff --git a/Kemkas.Web/wwwroot/img/discord-logo-blue.svg b/Kemkas.Web/wwwroot/img/discord-logo-blue.svg new file mode 100644 index 0000000..1c8d2a9 --- /dev/null +++ b/Kemkas.Web/wwwroot/img/discord-logo-blue.svg @@ -0,0 +1 @@ + \ No newline at end of file