Skip to content
This repository was archived by the owner on Nov 29, 2025. It is now read-only.

Commit 6064753

Browse files
authored
Merge pull request #32 from MicroPyramid/codex/refactor-login-page-param-handling
Fix token params in login
2 parents 9585804 + ccecaef commit 6064753

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/routes/(no-layout)/login/+page.server.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import prisma from '$lib/prisma'
33

44
import { redirect } from '@sveltejs/kit';
55
import { env } from '$env/dynamic/private';
6-
import { auth } from '$lib/stores/auth';
76

87
// import bcrypt from "bcryptjs";
98
import { v4 as uuidv4 } from 'uuid';
@@ -26,13 +25,13 @@ async function fetchUserData(params) {
2625
}
2726

2827
/** @type {import('@sveltejs/kit').ServerLoad} */
29-
export async function load({ params, url, cookies }) {
28+
export async function load({ url, cookies }) {
3029
const code = url.searchParams.get('code')
3130
const redirect_uri = env.GOOGLE_LOGIN_DOMAIN + '/login'
3231

3332
// Check if the user is already authenticated
3433
if (code != null) {
35-
params = {
34+
const tokenParams = {
3635
grant_type: 'authorization_code',
3736
code,
3837
redirect_uri,
@@ -42,7 +41,7 @@ export async function load({ params, url, cookies }) {
4241
let info
4342

4443
try {
45-
const response = await axios.post('https://accounts.google.com/o/oauth2/token', params)
44+
const response = await axios.post('https://accounts.google.com/o/oauth2/token', tokenParams)
4645
info = response.data
4746
} catch (error) {
4847
console.error('Error:', error)
@@ -52,7 +51,7 @@ export async function load({ params, url, cookies }) {
5251

5352
const session_id = uuidv4()
5453

55-
const user = await prisma.user.upsert({
54+
await prisma.user.upsert({
5655
where: { email: user_info.email },
5756
update: {
5857
session_id: session_id,

0 commit comments

Comments
 (0)