diff --git a/SharpbinV3.Client/src/lib/components/Navbar.svelte b/SharpbinV3.Client/src/lib/components/Navbar.svelte index 21c0817..0ccc549 100644 --- a/SharpbinV3.Client/src/lib/components/Navbar.svelte +++ b/SharpbinV3.Client/src/lib/components/Navbar.svelte @@ -3,6 +3,7 @@ import { resolve } from '$app/paths'; import { page } from '$app/state'; import { clearTokens } from '$lib/utils/auth'; + import type { PageData } from '../../routes/$types'; function logout() { clearTokens(); @@ -10,6 +11,10 @@ window.location.href = '/'; } + export let data: PageData; + + console.log(data); + let currentPath = page.url.pathname; let returnParam = currentPath !== '/' && !currentPath.startsWith('/login') && !currentPath.startsWith('/register') @@ -35,12 +40,18 @@ {:else}
LoginLogin RegisterRegister
{/if} diff --git a/SharpbinV3.Client/src/routes/+layout.svelte b/SharpbinV3.Client/src/routes/+layout.svelte index 20d0b4f..f75175e 100644 --- a/SharpbinV3.Client/src/routes/+layout.svelte +++ b/SharpbinV3.Client/src/routes/+layout.svelte @@ -45,5 +45,5 @@ {/if} - + diff --git a/SharpbinV3.Server/Controllers/AuthController.cs b/SharpbinV3.Server/Controllers/AuthController.cs index 21029da..03c0334 100644 --- a/SharpbinV3.Server/Controllers/AuthController.cs +++ b/SharpbinV3.Server/Controllers/AuthController.cs @@ -23,6 +23,8 @@ namespace SharpbinV3.Server.Controllers [Route("register")] public async Task Register([FromBody] RegisterRequest request) { + if (!options.Value.Registration_Enabled) + return BadRequest(new { message = "Registration is disabled." }); if (!await _verification.VerifyAsync(request.Token, Utilities.GetRequestIP(HttpContext))) return BadRequest(new { message = "Verification failed." }); @@ -106,7 +108,8 @@ namespace SharpbinV3.Server.Controllers var authSettings = options.Value; return Ok(new { - cf_turnstile_site_key = string.IsNullOrEmpty(authSettings.CF_Turnstile_SiteKey) ? null : authSettings.CF_Turnstile_SiteKey + cf_turnstile_site_key = string.IsNullOrEmpty(authSettings.CF_Turnstile_SiteKey) ? null : authSettings.CF_Turnstile_SiteKey, + registration_enabled = authSettings.Registration_Enabled }); } diff --git a/SharpbinV3.Server/Settings/AuthSettings.cs b/SharpbinV3.Server/Settings/AuthSettings.cs index 0553836..7b2f2c6 100644 --- a/SharpbinV3.Server/Settings/AuthSettings.cs +++ b/SharpbinV3.Server/Settings/AuthSettings.cs @@ -4,5 +4,6 @@ { public string CF_Turnstile_SiteKey { get; set; } = string.Empty; public string CF_Turnstile_SecretKey { get; set; } = string.Empty; + public bool Registration_Enabled { get; set; } = true; } }