1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import { error, redirect } from '@sveltejs/kit';
import { get, post, auth } from '$lib/utils';
import { PUBLIC_BTC as btc } from '$env/static/public';
export async function load({ cookies, locals, request, url, params }) {
url.pathname;
let token = cookies.get('token');
let rate,
rates = { USD: 1 },
subject;
let { user } = locals;
if (user) {
if (!user.pubkey && !url.pathname.includes('gen'))
throw redirect(307, `/${user.username}/generate`);
let account = user.accounts.find((a) => a.asset === btc && !a.pubkey);
if (account) {
let { id } = account;
if (user.account_id !== id) {
user = await post('/shiftAccount', { id }, auth(cookies));
}
}
}
try {
rate = await get('/rate');
rates = await get('/rates');
} catch (e) {}
return { subject, user, token, rate, rates };
}
|