mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
feat: TelegramLoginButton with OIDC popup + legacy widget fallback
- Add oidc_enabled/oidc_client_id to TelegramWidgetConfig interface and fallback - Add loginTelegramOIDC API method for id_token auth - Add loginWithTelegramOIDC to auth store - Rewrite TelegramLoginButton: OIDC popup when enabled, legacy widget otherwise - Extend Window.Telegram type with Login SDK in vite-env.d.ts
This commit is contained in:
@@ -37,6 +37,7 @@ interface AuthState {
|
||||
checkAdminStatus: () => Promise<void>;
|
||||
loginWithTelegram: (initData: string) => Promise<void>;
|
||||
loginWithTelegramWidget: (data: TelegramWidgetData) => Promise<void>;
|
||||
loginWithTelegramOIDC: (idToken: string) => Promise<void>;
|
||||
loginWithEmail: (email: string, password: string) => Promise<void>;
|
||||
loginWithOAuth: (
|
||||
provider: string,
|
||||
@@ -285,6 +286,21 @@ export const useAuthStore = create<AuthState>()(
|
||||
await get().checkAdminStatus();
|
||||
},
|
||||
|
||||
loginWithTelegramOIDC: async (idToken) => {
|
||||
const campaignSlug = consumeCampaignSlug();
|
||||
const referralCode = consumeReferralCode();
|
||||
const response = await authApi.loginTelegramOIDC(idToken, campaignSlug, referralCode);
|
||||
tokenStorage.setTokens(response.access_token, response.refresh_token);
|
||||
set({
|
||||
accessToken: response.access_token,
|
||||
refreshToken: response.refresh_token,
|
||||
user: response.user,
|
||||
isAuthenticated: true,
|
||||
pendingCampaignBonus: response.campaign_bonus || null,
|
||||
});
|
||||
await get().checkAdminStatus();
|
||||
},
|
||||
|
||||
loginWithEmail: async (email, password) => {
|
||||
const campaignSlug = consumeCampaignSlug();
|
||||
const referralCode = consumeReferralCode();
|
||||
|
||||
Reference in New Issue
Block a user