diff --git a/app/account/connect-telegram/page.tsx b/app/account/connect-telegram/page.tsx
index e2276d7..0ec500f 100644
--- a/app/account/connect-telegram/page.tsx
+++ b/app/account/connect-telegram/page.tsx
@@ -75,6 +75,9 @@ export default function Page() {
>
Continue
+
+ {/* Support LoginUrl */}
+
>
);
diff --git a/components/account/TelegramLogin.tsx b/components/account/TelegramLogin.tsx
index 792d0ee..2724c31 100644
--- a/components/account/TelegramLogin.tsx
+++ b/components/account/TelegramLogin.tsx
@@ -5,8 +5,11 @@ import TelegramLoginButton, {
} from "@/components/account/TelegramLoginButton";
import { accounts } from "@/lib/accounts";
import { useQueryClient } from "@tanstack/react-query";
+import { useSearchParams } from "next/navigation";
+import { useEffect } from "react";
-export default function TelegramLogin() {
+export default function TelegramLogin({ showButton = true }) {
+ const searchParams = useSearchParams();
const queryClient = useQueryClient();
const { mutate: connectTelegram } = accounts.useProvidersTelegramConnect({
mutation: {
@@ -18,10 +21,25 @@ export default function TelegramLogin() {
},
});
+ useEffect(() => {
+ if (searchParams.has("id")) {
+ const telegramUser = TelegramUser.safeParse(
+ Object.fromEntries(searchParams.entries()),
+ );
+ if (telegramUser.success) {
+ connectTelegram({ data: telegramUser.data });
+ }
+ }
+ }, [searchParams, connectTelegram]);
+
const onAuth = (user: TelegramUser) => {
connectTelegram({ data: user });
};
+ if (!showButton) {
+ return null;
+ }
+
return (
;
export type TelegramLoginButtonProps = {
botName: string;
diff --git a/package-lock.json b/package-lock.json
index 2d08d9c..9ece66c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -44,7 +44,8 @@
"tailwindcss": "3.3.6",
"taze": "^0.13.3",
"typescript": "5.3.3",
- "usehooks-ts": "^3.0.2"
+ "usehooks-ts": "^3.0.2",
+ "zod": "^3.22.4"
}
},
"node_modules/@aashutoshrathi/word-wrap": {
@@ -12813,6 +12814,14 @@
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
+ },
+ "node_modules/zod": {
+ "version": "3.22.4",
+ "resolved": "https://registry.npmjs.org/zod/-/zod-3.22.4.tgz",
+ "integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==",
+ "funding": {
+ "url": "https://github.com/sponsors/colinhacks"
+ }
}
}
}
diff --git a/package.json b/package.json
index f6b071c..1b23be7 100755
--- a/package.json
+++ b/package.json
@@ -51,7 +51,8 @@
"tailwindcss": "3.3.6",
"taze": "^0.13.3",
"typescript": "5.3.3",
- "usehooks-ts": "^3.0.2"
+ "usehooks-ts": "^3.0.2",
+ "zod": "^3.22.4"
},
"lint-staged": {
"{app,components,lib,public}/**/*.{js,ts,jsx,tsx}": [