Discussing APIs and development related to customers, discounts, and order management.
On checkout, I need to be able to force login for specific customers based on the email address they provide:
let currentEmail = buyerIdentity?.email.current;
buyerIdentity?.email.subscribe(async (newEmail) => {
needsLogin = -1;
console.log(`email address changed: `, newEmail);
currentEmail = newEmail;
needsLogin = +(await checkForceLogin(currentEmail));
console.log(`needs Login: `, needsLogin);
if (needsLogin > 0) {
displayErrorBanner(
root,
"This email account requires you to log in."
);
}
});
Instead of displaying an error banner, I'd like to have a modal that contains a login form.
And then the next step is how do I validate the customer based on their input?
Thank you!
Chris
Solved! Go to the solution
This is an accepted solution.
No. Not even close. I'm not trying to trap their login. I'm trying to force a login if the customer email meets certain criteria.
buyerJourney.intercept(
async () => {
if (currentEmail !== buyerIdentity?.email.current) {
currentEmail = buyerIdentity?.email.current;
needsLogin = +(await checkForceLogin(currentEmail));
}
let returnBehavior = {
behavior: `allow`,
};
if (needsLogin > 0) {
returnBehavior = {
behavior: `block`,
reason: `Special Pricing and/or Net Payment`,
errors: [
{
message:
`This account requires you to log in.`,
},
],
};
}
.
.
.
});
Hi,
just make an sqlite DB in server. and connect your app with it and when ever they tried to login use endpoints from your server and verify it.
you need more help?
This is an accepted solution.
No. Not even close. I'm not trying to trap their login. I'm trying to force a login if the customer email meets certain criteria.
buyerJourney.intercept(
async () => {
if (currentEmail !== buyerIdentity?.email.current) {
currentEmail = buyerIdentity?.email.current;
needsLogin = +(await checkForceLogin(currentEmail));
}
let returnBehavior = {
behavior: `allow`,
};
if (needsLogin > 0) {
returnBehavior = {
behavior: `block`,
reason: `Special Pricing and/or Net Payment`,
errors: [
{
message:
`This account requires you to log in.`,
},
],
};
}
.
.
.
});