Skip to content

Commit

Permalink
fix: add telegram session passer
Browse files Browse the repository at this point in the history
  • Loading branch information
Aerilym committed Jul 4, 2024
1 parent a2eedd6 commit 7f6b1ff
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/auth/providers/telegram.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { AuthDataValidator } from '@telegram-auth/server';
import { objectToAuthDataMap } from '@telegram-auth/server/utils';
import { Session } from 'next-auth';
import { JWT } from 'next-auth/jwt';
import CredentialsProvider from 'next-auth/providers/credentials';

type TelegramProviderOptions = {
Expand Down Expand Up @@ -38,3 +40,13 @@ export const TelegramProvider = ({ botToken }: TelegramProviderOptions) =>
return obj;
},
});

export function handleTelegramSession({ session, token }: { session: Session; token: JWT }) {
if (token) {
console.log(token);
if (token?.picture?.includes('telegram')) {
// @ts-expect-error -- Next auth doesnt properly return the user id, this fixes that
session.user.telegramId = token.sub;
}
}
}

0 comments on commit 7f6b1ff

Please sign in to comment.