aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.env1
-rw-r--r--src/routes/+layout.server.js12
2 files changed, 12 insertions, 1 deletions
diff --git a/.env b/.env
index cdf37b2a..f9924dad 100644
--- a/.env
+++ b/.env
@@ -1 +1,2 @@
VITE_COINOS_URL=http://localhost:3119
+VITE_BTC=5ac9f65c0efcc4775e0baec4ec03abdde22473cd3cf33c0419ca290e0751b225
diff --git a/src/routes/+layout.server.js b/src/routes/+layout.server.js
index 2d95a899..fbd53cd0 100644
--- a/src/routes/+layout.server.js
+++ b/src/routes/+layout.server.js
@@ -1,7 +1,9 @@
import { error } from '@sveltejs/kit';
import cookie from 'cookie';
import { protectedRoutes } from '$lib/utils';
-import { get } from '$lib/utils';
+import { get, post, auth } from '$lib/utils';
+
+const btc = import.meta.env.VITE_BTC;
export async function load({ request, setHeaders, url, params }) {
let { token } = cookie.parse(request.headers.get('cookie') || '');
@@ -13,6 +15,14 @@ export async function load({ request, setHeaders, url, params }) {
if (protectedRoutes.find((p) => url.pathname.match(p))) {
if (user.username !== params.username) throw error(404, 'user not found');
}
+
+ 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(request));
+ }
+ }
}
rates = await get('/rates');