Compare commits

..

2 commits

Author SHA1 Message Date
8eca9f1ec5
Merge 0cdb41abb7 into 6678ded2f9 2024-08-19 21:41:30 +00:00
0cdb41abb7
fix: update user on login 2024-08-19 23:41:28 +02:00
2 changed files with 16 additions and 0 deletions

View file

@ -50,6 +50,20 @@ export async function GET(context: APIContext): Promise<Response> {
sessionCookie.value,
sessionCookie.attributes
);
await context.locals.runtime.env.DB.prepare(
"UPDATE user SET username = ?2, avatar = ?3, access_token = ?4,access_token_expiration = ?5, refresh_token = ?6 WHERE discord_id = ?1"
)
.bind(
discordUser.id,
discordUser.username,
discordUser.avatar,
tokens.accessToken,
tokens.accessTokenExpiresAt.getTime(),
tokens.refreshToken
)
.first<UserRow>();
return context.redirect("/dashboard");
}

View file

@ -8,6 +8,8 @@ export async function GET(context: APIContext): Promise<Response> {
scopes: ["identify", "guilds"],
});
console.log("login");
context.cookies.set("discord_oauth_state", state, {
path: "/",
secure: import.meta.env.PROD,