fix: telegram oauth in logged in email account
This commit is contained in:
@@ -194,7 +194,7 @@
|
|||||||
showLogin,
|
showLogin,
|
||||||
telegramSdk,
|
telegramSdk,
|
||||||
getTg: () => tg,
|
getTg: () => tg,
|
||||||
telegramOAuthClientId,
|
telegramOAuthClientId: () => telegramOAuthClientId,
|
||||||
currentLang: () => currentLang,
|
currentLang: () => currentLang,
|
||||||
normalizeLangCode,
|
normalizeLangCode,
|
||||||
updateLocalData: (updatedLanguage) => {
|
updateLocalData: (updatedLanguage) => {
|
||||||
@@ -1443,7 +1443,8 @@
|
|||||||
{userAgreementUrl}
|
{userAgreementUrl}
|
||||||
{userLanguage}
|
{userLanguage}
|
||||||
showLogout={!telegramMiniAppContext}
|
showLogout={!telegramMiniAppContext}
|
||||||
linkTelegramAccount={accountStore.linkTelegramAccount}
|
linkTelegramAccount={() =>
|
||||||
|
accountStore.linkTelegramAccount(() => telegramMiniAppInitData)}
|
||||||
logout={accountStore.logout}
|
logout={accountStore.logout}
|
||||||
{openAdminPanel}
|
{openAdminPanel}
|
||||||
{openExternalLink}
|
{openExternalLink}
|
||||||
|
|||||||
@@ -145,6 +145,12 @@ export function createAccountStore({
|
|||||||
clearPasswordCooldownTimer();
|
clearPasswordCooldownTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTelegramOAuthClientId() {
|
||||||
|
const value =
|
||||||
|
typeof telegramOAuthClientId === "function" ? telegramOAuthClientId() : telegramOAuthClientId;
|
||||||
|
return Number(value || 0);
|
||||||
|
}
|
||||||
|
|
||||||
function closeSetPasswordDialog() {
|
function closeSetPasswordDialog() {
|
||||||
state.update((s) => ({
|
state.update((s) => ({
|
||||||
...s,
|
...s,
|
||||||
@@ -318,19 +324,21 @@ export function createAccountStore({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function linkTelegramAccount(getTelegramMiniAppInitData) {
|
async function linkTelegramAccount(getTelegramMiniAppInitData = () => "") {
|
||||||
const s = get(state);
|
const s = get(state);
|
||||||
if (s.linkTelegramBusy) return;
|
if (s.linkTelegramBusy) return;
|
||||||
|
const readTelegramMiniAppInitData =
|
||||||
|
typeof getTelegramMiniAppInitData === "function" ? getTelegramMiniAppInitData : () => "";
|
||||||
const isTelegramMiniAppAttempt = telegramSdk.hasLaunchParams();
|
const isTelegramMiniAppAttempt = telegramSdk.hasLaunchParams();
|
||||||
if (isTelegramMiniAppAttempt) {
|
if (isTelegramMiniAppAttempt) {
|
||||||
await telegramSdk.ensureForAction();
|
await telegramSdk.ensureForAction();
|
||||||
}
|
}
|
||||||
const initData = getTelegramMiniAppInitData();
|
const initData = readTelegramMiniAppInitData();
|
||||||
if (initData) {
|
if (initData) {
|
||||||
await linkTelegramAccountWithPayload({ init_data: initData });
|
await linkTelegramAccountWithPayload({ init_data: initData });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!telegramOAuthClientId) {
|
if (!getTelegramOAuthClientId()) {
|
||||||
showToast(t("wa_auth_telegram_not_configured"));
|
showToast(t("wa_auth_telegram_not_configured"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user