Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
add logging to logins
Browse files Browse the repository at this point in the history
  • Loading branch information
CelestialCrafter committed Dec 18, 2023
1 parent a266ba9 commit 7518f7c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/routes/identity/discord/+server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { error } from '@sveltejs/kit';
import { handleSignin } from '$lib/identity.server.js';
import { DISCORD_OAUTH_CLIENT_ID, DISCORD_OAUTH_CLIENT_SECRET } from '$env/static/private';
import { Issuer } from 'openid-client';
import { log } from '$lib/logging.server.js';

const callback = 'http://localhost:5173/identity/discord/';

Expand Down Expand Up @@ -40,6 +41,7 @@ export const GET = async ({ url, cookies }) => {

response = await client.userinfo(accessToken);
} catch (err) {
log.trace({ error: err }, 'discord login error');
throw error(401, 'Error logging in with Discord');
}

Expand Down
6 changes: 6 additions & 0 deletions src/routes/identity/google/+server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '$env/static/private';
import { Issuer } from 'openid-client';
import { createDecipheriv } from 'crypto';
import { log } from '$lib/logging.server.js';

const callback = 'http://localhost:5173/identity/google/';

Expand All @@ -30,6 +31,10 @@ export const GET = async ({ url, cookies }) => {
codeVerifier = decipher.update(encrypted);
codeVerifier = Buffer.concat([codeVerifier, decipher.final()]).toString();
} catch (err) {
log.trace(
{ error: err, code_verifier: cookies.get('code_verifier') },
'code verifier decryption error'
);
throw error(400, 'Bad Request');
}

Expand All @@ -44,6 +49,7 @@ export const GET = async ({ url, cookies }) => {
accessToken
);
} catch (err) {
log.trace({ error: err }, 'google login error');
throw error(401, 'Error logging in with Google');
}

Expand Down

0 comments on commit 7518f7c

Please sign in to comment.