Compare commits
6 Commits
680fb68ce2
...
4cd8a496b8
Author | SHA1 | Date |
---|---|---|
|
4cd8a496b8 | |
|
db02475eb3 | |
|
b1646fb2bd | |
|
078d1d473f | |
|
55831164ed | |
|
73dd219394 |
|
@ -1,6 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
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'
|
||||
},
|
||||
{
|
||||
title: 'More',
|
||||
title: 'Menu',
|
||||
path: '/more',
|
||||
svgPath: '/images/navigation/more.svg'
|
||||
}
|
||||
|
|
|
@ -5,10 +5,9 @@
|
|||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="application-name" content="OwlBoard" />
|
||||
<meta name="author" content="Frederick Boniface" />
|
||||
<meta name="description" content="Live train data, PIS Codes & reference data. Built by railway staff, for railway staff." />
|
||||
<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="viewport" content="width=device-width" />
|
||||
<meta name="theme-color" content="#00b7b7" />
|
||||
<link rel="icon" href="/images/icon.svg" type="image/svg+xml" />
|
||||
|
|
|
@ -4,11 +4,12 @@
|
|||
import Loading from '$lib/navigation/loading.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import { uuid } from '$lib/stores/uuid.js';
|
||||
import { checkAuth } from '$lib/libauth';
|
||||
|
||||
const title = 'Register';
|
||||
|
||||
let state = 'unreg';
|
||||
let isLoading = false;
|
||||
let isLoading = true;
|
||||
let inputValue = '';
|
||||
|
||||
function handleInput(event) {
|
||||
|
@ -39,17 +40,22 @@
|
|||
}
|
||||
|
||||
onMount(async () => {
|
||||
if ($uuid != 'null') {
|
||||
const auth = await checkAuth();
|
||||
if (auth.uuidPresent === false) {
|
||||
state = 'unreg';
|
||||
} else if (auth.uuidPresent === true) {
|
||||
state = 'reg';
|
||||
}
|
||||
isLoading = false;
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if isLoading}
|
||||
<Loading />
|
||||
{/if}
|
||||
|
||||
|
||||
<Header {title} />
|
||||
{#if isLoading}
|
||||
<Loading />
|
||||
{:else}
|
||||
{#if state == 'unreg'}
|
||||
<p>The staff version of OwlBoard offers several extra features:</p>
|
||||
<ul>
|
||||
|
@ -88,6 +94,7 @@
|
|||
browser.
|
||||
</p>
|
||||
{/if}
|
||||
{/if}
|
||||
<Nav />
|
||||
|
||||
<style>
|
||||
|
|
Loading…
Reference in New Issue