mirror of
https://github.com/gurucomputing/headscale-ui.git
synced 2026-01-23 02:34:43 +00:00
switchable registration and login window
This commit is contained in:
parent
30989d5fce
commit
ed2f0f2d35
3 changed files with 52 additions and 11 deletions
17
src/lib/components/login/auth-functions.svelte
Normal file
17
src/lib/components/login/auth-functions.svelte
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<script module lang="ts">
|
||||
import { appSettings } from '../common/state.svelte';
|
||||
|
||||
export async function loginOrRegister() {
|
||||
try {
|
||||
let authData = await appSettings.pb.collection('_superusers').authWithPassword('superadmin@breakglass.local', 'firsttimepasswordchangeme');
|
||||
if (authData) {
|
||||
appSettings.pb.authStore.clear();
|
||||
return 'registration';
|
||||
}
|
||||
} catch (error) {
|
||||
return 'login';
|
||||
}
|
||||
|
||||
return 'none';
|
||||
}
|
||||
</script>
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
}
|
||||
|
||||
// do an initial authentication check
|
||||
checkAuth();
|
||||
await checkAuth();
|
||||
|
||||
// delay load until page is hydrated
|
||||
appSettings.appLoaded = true;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,44 @@
|
|||
<script lang="ts">
|
||||
import { appSettings } from '$lib/components/common/state.svelte';
|
||||
import { fade } from 'svelte/transition';
|
||||
import { loginOrRegister } from '$lib/components/login/auth-functions.svelte';
|
||||
|
||||
appSettings.navbarTitle = 'Login';
|
||||
appSettings.sidebarDrawerOpen = false;
|
||||
|
||||
let loginType = $state('none');
|
||||
loginOrRegister().then(function (loginResult) {
|
||||
loginType = loginResult;
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="flex items-center justify-center">
|
||||
<fieldset class="fieldset bg-base-200 border-base-300 rounded-box w-xs border p-4">
|
||||
<legend class="fieldset-legend">Login</legend>
|
||||
{#if loginType == 'login'}
|
||||
<div in:fade class="flex items-center justify-center">
|
||||
<fieldset class="fieldset bg-base-200 border-base-300 rounded-box w-xs border p-4">
|
||||
<legend class="fieldset-legend">Login</legend>
|
||||
|
||||
<label class="label" for="email">Email</label>
|
||||
<input type="email" class="input" id="email" placeholder="Email" />
|
||||
<label class="label" for="email">Email</label>
|
||||
<input type="email" class="input" id="email" placeholder="Email" />
|
||||
|
||||
<label class="label" for="password">Password</label>
|
||||
<input type="password" class="input" id="password" placeholder="Password" />
|
||||
<label class="label" for="password">Password</label>
|
||||
<input type="password" class="input" id="password" placeholder="Password" />
|
||||
|
||||
<button class="btn btn-neutral mt-4">Login</button>
|
||||
</fieldset>
|
||||
</div>
|
||||
<button class="btn btn-neutral mt-4">Login</button>
|
||||
</fieldset>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if loginType == 'registration'}
|
||||
<div in:fade class="flex items-center justify-center">
|
||||
<fieldset class="fieldset bg-base-200 border-base-300 rounded-box w-xs border p-4">
|
||||
<legend class="fieldset-legend">First Time Registration</legend>
|
||||
|
||||
<label class="label" for="email">Email</label>
|
||||
<input type="email" required class="input validator" id="email" placeholder="Email" />
|
||||
<label class="label" for="password">New Password</label>
|
||||
<input type="password" class="input" id="password" placeholder="Password" />
|
||||
|
||||
<button class="btn btn-neutral mt-4" type="submit">Register Admin Account</button>
|
||||
</fieldset>
|
||||
</div>
|
||||
{/if}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue