-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add telegram and discord connect buttons to faucet
- Loading branch information
Showing
6 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID= | ||
NEXT_PUBLIC_SENT_STAKING_API_URL= | ||
FAUCET_WALLET_PRIVATE_KEY= | ||
NEXT_PUBLIC_ENV_FLAG= pick from dev, qa, stg, prd | ||
NEXT_PUBLIC_ENV_FLAG= pick from dev, qa, stg, prd | ||
DISCORD_CLIENT_ID= | ||
DISCORD_CLIENT_SECRET= | ||
TELEGRAM_BOT_TOKEN= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { createAuthHandler } from '@session/auth/api'; | ||
import { DiscordProvider, handleDiscordSession } from '@session/auth/providers/discord'; | ||
import { TelegramProvider } from '@session/auth/providers/telegram'; | ||
|
||
const discordClientId = process.env.DISCORD_CLIENT_ID; | ||
const discordClientSecret = process.env.DISCORD_CLIENT_SECRET; | ||
const telegramBotToken = process.env.TELEGRAM_BOT_TOKEN; | ||
|
||
if (!discordClientId || !discordClientSecret) { | ||
throw new Error('Discord client ID and client secret must be provided'); | ||
} | ||
|
||
if (!telegramBotToken) { | ||
throw new Error('Telegram bot token must be provided'); | ||
} | ||
|
||
export const { GET, POST } = createAuthHandler({ | ||
providers: [ | ||
DiscordProvider({ | ||
clientId: discordClientId, | ||
clientSecret: discordClientSecret, | ||
}), | ||
TelegramProvider({ botToken: telegramBotToken }), | ||
], | ||
callbacks: { | ||
async session({ session, token }) { | ||
handleDiscordSession({ session, token }); | ||
return session; | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { useSession } from '@session/auth/client'; | ||
|
||
export const AuthModule = () => { | ||
const { data, status } = useSession(); | ||
|
||
console.log(data); | ||
|
||
/** @ts-expect-error -- Workaround to get id */ | ||
const discordId = data?.user?.discordId; | ||
|
||
return <pre>{discordId}</pre>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
'use client'; | ||
import { NextAuthProvider } from '@session/auth/client'; | ||
import { DiscordAuthButton } from '@session/auth/components/DiscordAuthButton'; | ||
import { TelegramAuthButton } from '@session/auth/components/TelegramAuthButton'; | ||
import { AuthModule } from './AuthModule'; | ||
|
||
export default function FaucetPage() { | ||
return <div className="flex justify-center p-4 align-middle">{/* <FaucetModule /> */}</div>; | ||
return ( | ||
<NextAuthProvider> | ||
<div className="flex justify-center p-4 align-middle"> | ||
<AuthModule /> | ||
<DiscordAuthButton /> | ||
<TelegramButton /> | ||
</div> | ||
</NextAuthProvider> | ||
); | ||
} | ||
|
||
async function TelegramButton() { | ||
const csrfToken = ''; | ||
return <TelegramAuthButton csrfToken={csrfToken} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters