aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-11-02 22:45:38 -0700
committerAdam Soltys <[email protected]>2022-11-02 22:45:38 -0700
commit6417f26ed29dbb0c921e3cf07d1e8060b7a44550 (patch)
tree44462c6204374851541dadc7440b575ceba305f8 /src/routes
parent557e0f216dfde8cb6a852054b6413a0a85b4a08e (diff)
downloadcoinos-ui-6417f26ed29dbb0c921e3cf07d1e8060b7a44550.tar.gz
coinos-ui-6417f26ed29dbb0c921e3cf07d1e8060b7a44550.zip
move route checks to hooks
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/(app)/+layout.server.js14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/routes/(app)/+layout.server.js b/src/routes/(app)/+layout.server.js
index 6e17aaae..ee4c257e 100644
--- a/src/routes/(app)/+layout.server.js
+++ b/src/routes/(app)/+layout.server.js
@@ -1,5 +1,4 @@
import { error, redirect } from '@sveltejs/kit';
-import { protectedRoutes } from '$lib/utils';
import { get, post, auth } from '$lib/utils';
import { env } from '$env/dynamic/public';
@@ -8,20 +7,11 @@ export const { PUBLIC_BTC: btc } = env;
export async function load({ cookies, locals, request, url, params }) {
url.pathname;
let token = cookies.get('token');
- let user;
let rates;
let subject;
- if (token && token !== 'undefined') {
- user = locals.user;
-
- if (protectedRoutes.find((p) => url.pathname.match(p))) {
- if (user.username !== params.username) throw redirect(307, '/login');
- }
-
- if (['/login', '/register'].includes(url.pathname))
- throw redirect(307, `/${user.username}/dashboard`);
-
+ let { user } = locals;
+ if (user) {
let account = user.accounts.find((a) => a.asset === btc && !a.pubkey);
if (account) {
let { id } = account;