Adjustments to the registration page ref: OwlBoard/backend#39
This commit is contained in:
parent
55831164ed
commit
078d1d473f
@ -7,11 +7,16 @@ export interface libauthResponse {
|
|||||||
serverAuthCheckResponseCode?: number;
|
serverAuthCheckResponseCode?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface uuidCheckRes {
|
||||||
|
uuidValue?: string;
|
||||||
|
uuidPresent?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export async function checkAuth(): Promise<libauthResponse> {
|
export async function checkAuth(): Promise<libauthResponse> {
|
||||||
let result: libauthResponse = {};
|
let result: libauthResponse = {};
|
||||||
const uuidCheck = await checkUuid();
|
const uuidCheck = await checkUuid();
|
||||||
result.uuidPresent = uuidCheck.uuidPresent;
|
result.uuidPresent = uuidCheck?.uuidPresent;
|
||||||
result.uuidValue = uuidCheck.uuidValue;
|
result.uuidValue = uuidCheck?.uuidValue;
|
||||||
|
|
||||||
const serverCheck = await checkServerAuth();
|
const serverCheck = await checkServerAuth();
|
||||||
result.serverAuthCheck = serverCheck.authOk;
|
result.serverAuthCheck = serverCheck.authOk;
|
||||||
@ -20,35 +25,42 @@ export async function checkAuth(): Promise<libauthResponse> {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkUuid() {
|
export async function checkUuid(): Promise<uuidCheckRes> {
|
||||||
let uuid_value: string = '';
|
let uuid_value: string = '';
|
||||||
uuid.subscribe((value => uuid_value = value))
|
const unsubscribe = uuid.subscribe(value => {
|
||||||
|
uuid_value = value;
|
||||||
|
});
|
||||||
|
let res: uuidCheckRes = {
|
||||||
|
uuidValue: uuid_value
|
||||||
|
}
|
||||||
console.log("uuid-value is: ", uuid_value)
|
console.log("uuid-value is: ", uuid_value)
|
||||||
if (uuid_value && uuid_value != 'null') {
|
if (uuid_value && uuid_value != 'null') {
|
||||||
return {
|
res = {
|
||||||
uuidPresent: true,
|
uuidPresent: true,
|
||||||
uuidValue: uuid_value,
|
uuidValue: uuid_value,
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
return {
|
res = {
|
||||||
uuidPresent: false,
|
uuidPresent: false,
|
||||||
uuidValue: '',
|
uuidValue: uuid_value,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}unsubscribe()
|
||||||
|
return res;}
|
||||||
|
|
||||||
export async function checkServerAuth() {
|
export async function checkServerAuth() {
|
||||||
let uuid_value: string = '';
|
let uuid_value: string = '';
|
||||||
uuid.subscribe((value => uuid_value = value))
|
uuid.subscribe((value => uuid_value = value))
|
||||||
const url = "https://owlboard.info/api/v2/auth/check"
|
const url = "https://owlboard.info/api/v2/user/checkAuth"
|
||||||
const options = {
|
const options = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
uuid: uuid_value,
|
uuid: uuid_value,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const res = await fetch(url, options)
|
const res = await fetch(url, options)
|
||||||
let ok: boolean;
|
let ok: boolean;
|
||||||
if (res.status === 200) {
|
if (res.status !== 401) {
|
||||||
ok = true;
|
ok = true;
|
||||||
} else {
|
} else {
|
||||||
ok = false;
|
ok = false;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
const title = 'Register';
|
const title = 'Register';
|
||||||
|
|
||||||
let state = 'unreg';
|
let state = 'unreg';
|
||||||
let isLoading = false;
|
let isLoading = true;
|
||||||
let inputValue = '';
|
let inputValue = '';
|
||||||
|
|
||||||
function handleInput(event) {
|
function handleInput(event) {
|
||||||
@ -46,14 +46,16 @@
|
|||||||
} else if (auth.uuidPresent === true) {
|
} else if (auth.uuidPresent === true) {
|
||||||
state = 'reg';
|
state = 'reg';
|
||||||
}
|
}
|
||||||
|
isLoading = false;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if isLoading}
|
|
||||||
<Loading />
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<Header {title} />
|
<Header {title} />
|
||||||
|
{#if isLoading}
|
||||||
|
<Loading />
|
||||||
|
{:else}
|
||||||
{#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>
|
||||||
@ -92,6 +94,7 @@
|
|||||||
browser.
|
browser.
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
{/if}
|
||||||
<Nav />
|
<Nav />
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
Loading…
Reference in New Issue
Block a user