We are excited to announce the following two additions to the wix-users-backend API.
emailUser( )
The backend emailUser( ) function can be used to send a triggered email to any of your site’s members. It works just like the frontend emailUser( ), without the restriction of only being able to send emails to the currently logged in user.
To learn more, see emailUser( ) in the API reference.
generateSessionToken( )
The generateSessionToken( ) function is used to bypass Wix member authentication so that you can use a 3rd party service to authenticate your users. That means you can provide Single Sign-On (SSO) for users where they are authenticated by a non-Wix entity to login to your Wix site.
Sam, this might be what I need to have my users login ONLY with Google. Just 2 things:
in the API-doc example code there´s this:
import {authBy3rdParty} from 'backend/authentications';
But I cannot find this backend function anywhere. What did I miss?
2)does this SSO REPLACE the Wix interface (the Wix login dialog) when a page is requested that is restricted (e.g. because Wix looks for a backend file called “login.jsw”), or is it just to make your own page, but, if a user somehow accesses a resticted page WITHOUT having logged on using a custom login page, the standard Wix login dialog is still displayed?
Your link emailUser( ) directs to an example where everything is clear, but the most important thing is missing.
let userId = // get user ID
How to get the user ID, if it is not the current user? I have tried the _owner field, but the email function does not work.
wixUsers.emailUser(“emailID”, user._owner)
Any idea how to get the user ID of a non logged in member?
@yisrael-wix Can anyone shed some light on this, it’s exactly what i’m looking for and am struggling to implement this. Is there a working example with PETER’s question about the user ID? thank you
Hi @Peter, that’s great news!
I wondered if you would be able to provide the whole code as I still seem to be struggling… I have this as part of some code on a repeater, but it doesn’t seem to work
@stephenmccall
You should check if the “itemData._owner” is a correct value.
Use console.log(itemData._owner); and check if it is really the ID of the user you want to send the email.
Otherwise the wixUsers.emailUser(“emailID”,user._owner) works correct in my code.
Good luck
Thanks Peter, I’ve spent way too much time on this and just about have it working on a variable template through Sendgrid, seems as if it should have been so simple but I must have been missing something obvious.
Calling wixUsers.generateSessionToken(‘someone@example.com’) in backend jsw always return error “Unauthorized to perform this action with context ApiContext”. Does anyone know how to authorize that API call? Thank you!