Luca
02/17/2024, 3:30 AMpython
passwordless.init(passwordless.ContactConfig(
contact_method='EMAIL'),
flow_type='USER_INPUT_CODE_AND_MAGIC_LINK',
)
And this is the rontend config:
ts
import SuperTokens from 'supertokens-web-js';
import Session from 'supertokens-web-js/recipe/session';
import Passwordless from 'supertokens-web-js/recipe/passwordless'
const initSupertokens = () => {
SuperTokens.init({
appInfo: {
apiDomain: process.env.NEXT_PUBLIC_BACKEND_HOST!,
apiBasePath: "/auth",
appName: "CM",
},
recipeList: [
Session.init(),
Passwordless.init({}),
],
});
}
export default initSupertokens
after calling
import { createCode } from "supertokens-web-js/recipe/passwordless";
...
const resp = await createCode({email})
i am getting res.status = OK
Also my backend loggs:
"POST /auth/signinup/code HTTP/1.1" 200 OK
and returns:
json
{
"status": "OK",
"deviceId": "cY1ju3u88Tl7IDYc/JBf3duXTHoTbeAz5ujFr0ThODI=",
"preAuthSessionId": "2S0TLFvqwGH9jX7KRM-IBnS4oP8nd8e-JkmsB0JnilY",
"flowType": "USER_INPUT_CODE_AND_MAGIC_LINK"
}
But i am not getting any email. I tested several email addresses.Luca
02/17/2024, 3:30 AMpython
def email_delivery(original_implementation: EmailDeliveryOverrideInput) -> EmailDeliveryOverrideInput:
async def send_email(template_vars: EmailTemplateVars, user_context: Dict[str, Any]) -> None:
email = template_vars.email
magic_link = template_vars.url_with_link_code # magic link
otp = template_vars.user_input_code # OTP
valid_to_ms = template_vars.code_life_time
valid_to = (datetime.now() + timedelta(milliseconds=valid_to_ms)).strftime('%H:%M')
emails = EMailTemplateWorkflow(UUID_SYSTEM_USER)
if template_vars.tenant_id == 'customers':
emails.queue_customer_signinup_email(email, RenderCustomerSignInUpParams(
otp=otp,
magic_link=magic_link,
valid_to=valid_to
))
original_implementation.send_email = send_email
return original_implementation
...
passwordless.init(passwordless.ContactConfig(
contact_method='EMAIL'),
flow_type='USER_INPUT_CODE_AND_MAGIC_LINK',
email_delivery=EmailDeliveryConfig(
override=email_delivery
)
)
If i do this, my custom function send_email
is not called.
Do you have any idea what's going wrong here?rp_st
02/17/2024, 5:00 AMLuca
02/17/2024, 5:15 AMcom.supertokens {"t": "2024-02-17T05:12:48.371Z", "sdkVer": "0.18.7", "message": "middleware: Started", "file": "supertokens.py:571"}
com.supertokens {"t": "2024-02-17T05:12:48.371Z", "sdkVer": "0.18.7", "message": "middleware: requestRID is: passwordless", "file": "supertokens.py:584"}
com.supertokens {"t": "2024-02-17T05:12:48.371Z", "sdkVer": "0.18.7", "message": "middleware: Checking recipe ID for match: session", "file": "supertokens.py:595"}
com.supertokens {"t": "2024-02-17T05:12:48.371Z", "sdkVer": "0.18.7", "message": "middleware: Checking recipe ID for match: thirdpartyemailpassword", "file": "supertokens.py:595"}
com.supertokens {"t": "2024-02-17T05:12:48.371Z", "sdkVer": "0.18.7", "message": "middleware: Checking recipe ID for match: emailverification", "file": "supertokens.py:595"}
com.supertokens {"t": "2024-02-17T05:12:48.371Z", "sdkVer": "0.18.7", "message": "middleware: Checking recipe ID for match: passwordless", "file": "supertokens.py:595"}
com.supertokens {"t": "2024-02-17T05:12:48.372Z", "sdkVer": "0.18.7", "message": "middleware: Matched with recipe ID: passwordless", "file": "supertokens.py:621"}
com.supertokens {"t": "2024-02-17T05:12:48.372Z", "sdkVer": "0.18.7", "message": "middleware: Request being handled by recipe. ID is: /signinup/code", "file": "supertokens.py:634"}
INFO: 45.152.161.90:0 - "POST /auth/signinup/code HTTP/1.1" 200 OK
com.supertokens {"t": "2024-02-17T05:12:48.467Z", "sdkVer": "0.18.7", "message": "Sending response to client with status code: 200", "file": "utils.py:155"}
com.supertokens {"t": "2024-02-17T05:12:48.468Z", "sdkVer": "0.18.7", "message": "middleware: Ended", "file": "supertokens.py:650"}
rp_st
02/17/2024, 5:21 AMLuca
02/17/2024, 5:23 AMpython
passwordless.init(passwordless.ContactConfig(
contact_method='EMAIL'),
flow_type='USER_INPUT_CODE_AND_MAGIC_LINK',
email_delivery=EmailDeliveryConfig(
override=email_delivery
)
)
rp_st
02/17/2024, 5:23 AMrp_st
02/17/2024, 5:24 AMLuca
02/17/2024, 5:24 AMLuca
02/17/2024, 5:24 AMrp_st
02/17/2024, 5:25 AMrp_st
02/17/2024, 5:26 AMfrom supertokens_python.recipe.passwordless import ContactEmailOnlyConfig
rp_st
02/17/2024, 5:27 AMContactEmailOnlyConfig
vs checking if the config.contact_method == 'EMAIL'rp_st
02/17/2024, 5:28 AMpasswordless.ContactConfig(contact_method='EMAIL')
(or do we?)rp_st
02/17/2024, 5:29 AMLuca
02/17/2024, 5:29 AMrp_st
02/17/2024, 5:29 AMLuca
02/17/2024, 5:30 AMLuca
02/17/2024, 5:31 AMrp_st
02/17/2024, 5:36 AMrp_st
02/17/2024, 5:36 AMrp_st
02/17/2024, 5:36 AMLuca
02/17/2024, 5:43 AM