+
@@ -62,6 +79,14 @@ export function CustomLoginForm() {
>
{isConnecting ? "Submitting..." : "Submit"}
+
Or
+
{error &&
{error.message}
}
);
diff --git a/packages/thirdweb/src/wallets/in-app/core/interfaces/connector.ts b/packages/thirdweb/src/wallets/in-app/core/interfaces/connector.ts
index 7c2f5170d4f..5afe7d25df4 100644
--- a/packages/thirdweb/src/wallets/in-app/core/interfaces/connector.ts
+++ b/packages/thirdweb/src/wallets/in-app/core/interfaces/connector.ts
@@ -21,7 +21,7 @@ export interface InAppConnector {
strategy: SocialAuthOption,
mode?: "redirect" | "popup" | "window",
redirectUrl?: string,
- ): void;
+ ): Promise
;
// Login takes an auth token and connects a user with it
loginWithAuthToken?(
authResult: AuthStoredTokenWithCookieReturnType,
diff --git a/packages/thirdweb/src/wallets/in-app/core/wallet/index.ts b/packages/thirdweb/src/wallets/in-app/core/wallet/index.ts
index accf32262a6..990a5d6ef9c 100644
--- a/packages/thirdweb/src/wallets/in-app/core/wallet/index.ts
+++ b/packages/thirdweb/src/wallets/in-app/core/wallet/index.ts
@@ -46,7 +46,7 @@ export async function connectInAppWallet(
) {
const strategy = options.strategy;
if (socialAuthOptions.includes(strategy as SocialAuthOption)) {
- connector.authenticateWithRedirect(
+ await connector.authenticateWithRedirect(
strategy as SocialAuthOption,
createOptions?.auth?.mode,
createOptions?.auth?.redirectUrl,
diff --git a/packages/thirdweb/src/wallets/in-app/web/lib/auth/oauth.ts b/packages/thirdweb/src/wallets/in-app/web/lib/auth/oauth.ts
index 017672ff091..39629b20414 100644
--- a/packages/thirdweb/src/wallets/in-app/web/lib/auth/oauth.ts
+++ b/packages/thirdweb/src/wallets/in-app/web/lib/auth/oauth.ts
@@ -26,13 +26,13 @@ const closeWindow = ({
}
};
-export const loginWithOauthRedirect = (options: {
+export async function loginWithOauthRedirect(options: {
authOption: OAuthOption;
client: ThirdwebClient;
ecosystem?: Ecosystem;
redirectUrl?: string;
mode?: "redirect" | "popup" | "window";
-}): void => {
+}): Promise {
const loginUrl = getLoginUrl({
...options,
mode: options.mode || "redirect",
@@ -42,7 +42,10 @@ export const loginWithOauthRedirect = (options: {
} else {
window.open(loginUrl);
}
-};
+ // wait for 5 secs for the redirect to happen
+ // that way it interrupts the rest of the execution that would normally keep connecting
+ await new Promise((resolve) => setTimeout(resolve, 5000));
+}
export const loginWithOauth = async (options: {
authOption: OAuthOption;
diff --git a/packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts b/packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts
index 57844579aef..78626542908 100644
--- a/packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts
+++ b/packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts
@@ -260,12 +260,12 @@ export class InAppWebConnector implements InAppConnector {
});
}
- authenticateWithRedirect(
+ async authenticateWithRedirect(
strategy: SocialAuthOption,
mode?: "redirect" | "popup" | "window",
redirectUrl?: string,
- ): void {
- loginWithOauthRedirect({
+ ): Promise {
+ return loginWithOauthRedirect({
authOption: strategy,
client: this.client,
ecosystem: this.ecosystem,