diff options
| author | Adam Soltys <[email protected]> | 2022-08-19 23:13:01 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-08-19 23:13:01 -0700 |
| commit | b3eefc07a56ea934de126c0d039943edacffa95c (patch) | |
| tree | 125cf73b09bb95eb0a79608f4ee5eaf1442b8e5f /src/hooks | |
| parent | e126a0ee16178f81c23934829d6d64eef7e8b7fb (diff) | |
| download | coinos-ui-b3eefc07a56ea934de126c0d039943edacffa95c.tar.gz coinos-ui-b3eefc07a56ea934de126c0d039943edacffa95c.zip | |
get login and register working again
Diffstat (limited to 'src/hooks')
| -rw-r--r-- | src/hooks/index.js | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/src/hooks/index.js b/src/hooks/index.js deleted file mode 100644 index 2284d88d..00000000 --- a/src/hooks/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import cookie from 'cookie'; -import { get } from '$lib/utils'; -import { protectedRoutes } from '$lib/utils'; - -export async function handle({ event, resolve }) { - let { - params, - request: { headers } - } = event; - - const cookies = cookie.parse(headers.get('cookie') || ''); - let { token } = cookies; - event.locals = { token }; - - if (protectedRoutes.find((p) => event.url.pathname.match(p))) { - let user = await get('/me', { accept: 'application/json', authorization: `Bearer ${token}` }); - if (user.username !== params.username) throw new Error('user not found'); - } - - return resolve(event); -} - -export const getSession = ({ locals: { token } }) => { - return { token }; -}; |
