wix-users/ wix-crm Registration using email with approvalToken problem

Tom, Ben, Shlomi and the wix team I am happy to take guidance on what I may be doing wrong but I think we have incomplete or broken functionality here.

I have been trying to develop a member registration page using the wix-users.register() in conjunction with either wix-users.emailUser() or wix-crm.emailContact(). The idea is as follows and is a derivative of the Register a user sending an email for confirmation process described in the wix-users.approveByToken() documentation here:
https://www.wix.com/code/reference/wix-users-backend.html#approveByToken

So the basic flow I am trying to perform includes wix.users/wix.users-backend/wix.crm/wix-crm-backend/wix-router and looks like this


While trying to build this I have encountered some documentation errors and problems with Wix’s assumptions associated with this process.

Let’s start with documentation errors:

In this flow, from the documentation referenced above, there is a call to wix-users-backend.emailUser()…


This function doesn’t exist in wix-users-backend :frowning: It doesn’t exist in wix-crm-backend either.
So the only recourse is to use the client side version of either of these as follows:


As you can see from the graphic, Wix on the client side assumes (quite rightly, possibly, for security purposes) that the user is known to the web site before permitting the email interface to be used.

So in the case of wix-users the user must be logged in “User must be logged-in in order to send an email” before a triggered email can be sent. This, presumably, is because the wix-users interface actually ignores the contact id it wants in the argument list and wants to see the wix-users.currentUser.id there and the loggedIn status needs to be loggedIn (question here is - why bother with a contact id in the argument list if this is the case?).

In the case of wix-crm things are a little more esoteric. It complains with “contactId does not match current session contact (401)” which is another way of saying “this user is not logged in” [;-)].

So even though the Wix documentation states you can use a deferred registration technique for enhanced security using approval tokens. You really can’t :-).

Lastly, there has been another thread addressing variable substitution in triggered emails.

One of the things you want to do in a triggered email is send a ‘nice’ looking email where complex URLs are masked in text or behind a button as a link. However, you cannot use variables in links on triggered emails which is a problem. Yes you can rely on a URL being clickable when added as text but tokens are long and complicated. So rather than present my prospective member with a text url that looks like:

https://www.domain.com/membership/confirmRegistration/JWS.eyJraWQiOiJSc012MmV3MiIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wiaWRcIjpcIjIzZWJhYmQ4LTVhZmMtNGY2Ny04ZjI1LTc1YjUxNzc4NThjOFwiLFwiY29sbGVjdGlvbklkXCI6XCIzZWY2NDk0MC1mZWUwLTQ3YTUtOGFmMy1mMDZjYzdlZDY1ZjJcIn0iLCJpYXQiOjE1MzE3NjE5MTksImV4cCI6MTUzMTc2MjIxOX0.Jam1VTdkrZlt_Fgc4T1Rq1MNQKzEo4y0-M4ZeR4IJy8
I would rather present them with either a text link:

                 Click Here to Verify

or a button


One last point. Why doesn’t wix-users also offer an equivalent login() function that permits a custom login page to be developed?

Cheers
Steve

3 Likes

Just to add to this. Wix does now offer a login() function which permits a custom login page to be developed!! Nice job and a welcome addition.

Now to sort out the user registration token verify which is doable but still requires the use of wix-crm AND wix-users to work.

1 Like

Is there a video tutorial for this? This would be helpful for me.

While Wix Corvid fixed the issues describe above, this week the same problems are back:

https://www.wix.com/corvid/forum/community-discussion/fails-wix-users-backend-approvebytoken?origin=member_posts_page