I’m having trouble with
Implementing a custom registration → email-verification flow using Velo’s backend wix-users-backend.register() and approveByToken() pattern. My code registers the user server-side, sends an “approval” email via emailUser(…), and then (on /post-register?token=…) approves and logs them in. Instead of landing in the “Verify Email” state or successfully emailing my template, I get backend errors like:
Not Found: the requested item no longer exists.- Frontend “Registration error: Unable to handle the request. Contact the site administrator…”
Working in
Wix Studio (Dev Mode) with Velo code files (.jsw backend modules + page code in a lightbox multi-state).
What I’m trying to do
- Register a new member backend-side:
js
CopyEdit
const result = await wixUsersBackend.register(email, password, { contactInfo: { … } });
await wixUsersBackend.emailUser('verifyRegistration', result.user.id, { variables: { verifyLink: `…?token=${result.approvalToken}` } });
- Approve them when they click my email link:
js
CopyEdit
const { sessionToken } = await wixUsersBackend.approveByToken(token);
wixUsers.applySessionToken(sessionToken);
- Drive this all through a single lightbox with states:
registration→verifyEmailState→registrationSuccess.
What I’ve tried so far
- Confirmed Require email verification is ON in Site Members settings.
- Ensured my email-automation template key (
verifyRegistration) exactly matches the template in Dashboard. - Switched from
result.user._idtoresult.user.idper the UUID requirement. - Wrapped
emailUserintry/catchto throw clear errors on “Not Found.” - Added logging to both backend and frontend to trace the flow.
- Experimented with using
session(Wix Storage) instead oflocalStoragefor tokens. - Tried both the built-in
authentication.register()OTP flow and theapproveByToken()approach.
Extra context
- Errors:
- Backend:
Not Found: the requested item no longer exists.(onemailUser) - Frontend:
Registration error: Unable to handle the request…
- Backend:
- Code snippets and full logs are available upon request—happy to share more detail.
- I’d like to keep using my existing multi-state lightbox and only tweak as needed for this flow.
Any insights on why emailUser can’t find my template, or how to correctly wire the approval token pattern in Velo, would be hugely appreciated!