Skip to content

Commit 31e958e

Browse files
committed
Adds captcha to email passwordless
1 parent 8e5c8f9 commit 31e958e

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

packages/modal/src/ui/components/Login/Login.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,11 @@ function Login(props: LoginProps) {
186186
authBuildEnv,
187187
});
188188

189-
let token = "";
190-
if (authConnection === AUTH_CONNECTION.SMS_PASSWORDLESS) {
191-
const res = await captchaRef.current?.execute({ async: true });
192-
if (!res) {
193-
throw WalletLoginError.connectionError("Captcha token is required");
194-
}
195-
token = res.response;
189+
const res = await captchaRef.current?.execute({ async: true });
190+
if (!res) {
191+
throw WalletLoginError.connectionError("Captcha token is required");
196192
}
193+
const token = res.response;
197194

198195
const result = await handler.sendVerificationCode({ captchaToken: token });
199196
if (result?.error) {

packages/modal/src/ui/handlers/AbstractHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export abstract class PasswordlessHandler {
120120
};
121121
}
122122

123-
abstract sendVerificationCode(params?: { captchaToken: string }): Promise<IStartResponse>;
123+
abstract sendVerificationCode(params: { captchaToken: string }): Promise<IStartResponse>;
124124

125125
abstract verifyCode(code: string): Promise<IVerifyResponse>;
126126
}

packages/modal/src/ui/handlers/EmailPasswordlessHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class EmailPasswordlessHandler extends PasswordlessHandler {
1414
if (this.sessionStorageAvailable) this.trackingId = window.sessionStorage.getItem("trackingId") ?? undefined;
1515
}
1616

17-
async sendVerificationCode() {
17+
async sendVerificationCode({ captchaToken }: { captchaToken?: string }) {
1818
const { loginHint, network, web3authClientId } = this.passwordlessParams;
1919

2020
const finalParams: CodeInitiateRequestBodyParams = {
@@ -27,6 +27,7 @@ export default class EmailPasswordlessHandler extends PasswordlessHandler {
2727
version: "",
2828
network,
2929
flow_type: EMAIL_FLOW.code,
30+
captcha_token: captchaToken,
3031
};
3132

3233
return super.start(finalParams);

0 commit comments

Comments
 (0)