Skip to content

Commit

Permalink
do some renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasptsch committed Jan 11, 2025
1 parent 97d2155 commit 618c8c7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/frontend/app/routes/api/auth.discord.callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,27 @@ export const APIRoute = createAPIFileRoute("/api/auth/discord/callback")({
});
}

const discordUser = await api.users.get("@me");
const { id, username } = await api.users.get("@me");

const guildMember = await api.users.getGuildMember(env.VITE_GUILD_ID);
const { nick, roles } = await api.users.getGuildMember(env.VITE_GUILD_ID);

const { accessToken, refreshToken, accessTokenExpiresAt } = tokens

const [authedUser] = await db
.insert(userTable)
.values({
id: discordUser.id,
username: guildMember.nick || discordUser.username,
roles: guildMember.roles,
id,
username: nick || username,
roles: roles,
accessToken,
refreshToken,
accessTokenExpiresAt,
})
.onConflictDoUpdate({
target: userTable.id,
set: {
username: guildMember.nick || discordUser.username,
roles: guildMember.roles,
username: nick || username,
roles: roles,
updatedAt: new Date().toISOString(),
accessToken,
refreshToken,
Expand All @@ -99,7 +99,7 @@ export const APIRoute = createAPIFileRoute("/api/auth/discord/callback")({
});
}

const session = await lucia.createSession(discordUser.id, {});
const session = await lucia.createSession(id, {});

const sessionCookie = lucia.createSessionCookie(session.id);
setCookie(
Expand Down

0 comments on commit 618c8c7

Please sign in to comment.