Compare commits
No commits in common. "4cd8a496b88226eab6dd6a5b8d6c56ccc7f7ee3d" and "680fb68ce2afbea94b94d1ca7be415d83ce3cd8e" have entirely different histories.
4cd8a496b8
...
680fb68ce2
|
@ -1,7 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
</head>
|
</head>
|
||||||
<body data-sveltekit-preload-data="hover">
|
<body data-sveltekit-preload-data="hover">
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
import { uuid } from "./stores/uuid"
|
|
||||||
|
|
||||||
export interface libauthResponse {
|
|
||||||
uuidPresent?: boolean;
|
|
||||||
serverAuthCheck?: boolean;
|
|
||||||
uuidValue?: string;
|
|
||||||
serverAuthCheckResponseCode?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface uuidCheckRes {
|
|
||||||
uuidValue?: string;
|
|
||||||
uuidPresent?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function checkAuth(): Promise<libauthResponse> {
|
|
||||||
let result: libauthResponse = {};
|
|
||||||
const uuidCheck = await checkUuid();
|
|
||||||
result.uuidPresent = uuidCheck?.uuidPresent;
|
|
||||||
result.uuidValue = uuidCheck?.uuidValue;
|
|
||||||
|
|
||||||
const serverCheck = await checkServerAuth();
|
|
||||||
result.serverAuthCheck = serverCheck.authOk;
|
|
||||||
result.serverAuthCheckResponseCode = serverCheck.status;
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function checkUuid(): Promise<uuidCheckRes> {
|
|
||||||
let uuid_value: string = '';
|
|
||||||
const unsubscribe = uuid.subscribe(value => {
|
|
||||||
uuid_value = value;
|
|
||||||
});
|
|
||||||
let res: uuidCheckRes = {
|
|
||||||
uuidValue: uuid_value
|
|
||||||
}
|
|
||||||
console.log("uuid-value is: ", uuid_value)
|
|
||||||
if (uuid_value && uuid_value != 'null') {
|
|
||||||
res = {
|
|
||||||
uuidPresent: true,
|
|
||||||
uuidValue: uuid_value,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
res = {
|
|
||||||
uuidPresent: false,
|
|
||||||
uuidValue: uuid_value,
|
|
||||||
}
|
|
||||||
|
|
||||||
}unsubscribe()
|
|
||||||
return res;}
|
|
||||||
|
|
||||||
export async function checkServerAuth() {
|
|
||||||
let uuid_value: string = '';
|
|
||||||
uuid.subscribe((value => uuid_value = value))
|
|
||||||
const url = "https://owlboard.info/api/v2/user/checkAuth"
|
|
||||||
const options = {
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
uuid: uuid_value,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const res = await fetch(url, options)
|
|
||||||
let ok: boolean;
|
|
||||||
if (res.status !== 401) {
|
|
||||||
ok = true;
|
|
||||||
} else {
|
|
||||||
ok = false;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
authOk: ok,
|
|
||||||
status: res.status,
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,7 +11,7 @@
|
||||||
svgPath: '/images/navigation/info.svg'
|
svgPath: '/images/navigation/info.svg'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Menu',
|
title: 'More',
|
||||||
path: '/more',
|
path: '/more',
|
||||||
svgPath: '/images/navigation/more.svg'
|
svgPath: '/images/navigation/more.svg'
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
<meta name="application-name" content="OwlBoard" />
|
<meta name="application-name" content="OwlBoard" />
|
||||||
<meta name="author" content="Frederick Boniface" />
|
<meta name="author" content="Frederick Boniface" />
|
||||||
<meta name="description" content="Get instant access to live train data, PIS codes, and location reference codes. Built by railway staff, for railway staff – your fastest route to accurate information." />
|
<meta name="description" content="Live train data, PIS Codes & reference data. Built by railway staff, for railway staff." />
|
||||||
<meta name="viewport" content="width=device-width" />
|
<meta name="viewport" content="width=device-width" />
|
||||||
<meta name="theme-color" content="#00b7b7" />
|
<meta name="theme-color" content="#00b7b7" />
|
||||||
<link rel="icon" href="/images/icon.svg" type="image/svg+xml" />
|
<link rel="icon" href="/images/icon.svg" type="image/svg+xml" />
|
||||||
|
|
|
@ -4,12 +4,11 @@
|
||||||
import Loading from '$lib/navigation/loading.svelte';
|
import Loading from '$lib/navigation/loading.svelte';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { uuid } from '$lib/stores/uuid.js';
|
import { uuid } from '$lib/stores/uuid.js';
|
||||||
import { checkAuth } from '$lib/libauth';
|
|
||||||
|
|
||||||
const title = 'Register';
|
const title = 'Register';
|
||||||
|
|
||||||
let state = 'unreg';
|
let state = 'unreg';
|
||||||
let isLoading = true;
|
let isLoading = false;
|
||||||
let inputValue = '';
|
let inputValue = '';
|
||||||
|
|
||||||
function handleInput(event) {
|
function handleInput(event) {
|
||||||
|
@ -40,22 +39,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const auth = await checkAuth();
|
if ($uuid != 'null') {
|
||||||
if (auth.uuidPresent === false) {
|
|
||||||
state = 'unreg';
|
|
||||||
} else if (auth.uuidPresent === true) {
|
|
||||||
state = 'reg';
|
state = 'reg';
|
||||||
}
|
}
|
||||||
isLoading = false;
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Header {title} />
|
|
||||||
{#if isLoading}
|
{#if isLoading}
|
||||||
<Loading />
|
<Loading />
|
||||||
{:else}
|
{/if}
|
||||||
|
|
||||||
|
<Header {title} />
|
||||||
{#if state == 'unreg'}
|
{#if state == 'unreg'}
|
||||||
<p>The staff version of OwlBoard offers several extra features:</p>
|
<p>The staff version of OwlBoard offers several extra features:</p>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -94,7 +88,6 @@
|
||||||
browser.
|
browser.
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
|
||||||
<Nav />
|
<Nav />
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
Loading…
Reference in New Issue