Skip to content

Commit

Permalink
chore: properly type telegram object
Browse files Browse the repository at this point in the history
  • Loading branch information
Aerilym committed Jul 4, 2024
1 parent d59c7af commit 8b00a97
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions packages/auth/providers/telegram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,18 @@ export const TelegramProvider = ({ botToken }: TelegramProviderOptions) =>
id: 'telegram',
name: 'Telegram',
credentials: {},
/** @ts-expect-error -- trust me im right */
async authorize(credentials, req) {
const validator = new AuthDataValidator({ botToken });

const data = objectToAuthDataMap(req.query || {});

const user = await validator.validate(data);

console.log('user');
console.log(user);

if (user.id && user.first_name) {
return {
id: user.id.toString(),
name: [user.first_name, user.last_name || ''].join(' '),
image: user.photo_url,
};
}

return null;
return {
id: user.id,
name: user.first_name,
email: user.username,
};
},
});

0 comments on commit 8b00a97

Please sign in to comment.