I’m looking to create the following flow in my app using actions:
- The user logs in, either using Google sign-in or by providing username and password.
- I want an action to check if there is a
given_name
field on the user (there will be if done with Google, there won’t if done with username and password (I think)). - If there is no
given_name
I want to redirect my user to my application where they can fill in those details. I’ll then use the Management API to update the user, and then use /continue to redirect back to the flow.
My action looks like this currently:
exports.onExecutePostLogin = async (event, api) => {
if (event.user && !(event.user.given_name) || !(event.user.family_name)){
api.redirect.sendUserTo('my-url/new-user')
}
};
The problem I’m having is that this is executing before the user gets to the Universal login page - so before any logging in is actually happening. Is this expected behaviour? How can I get the action to not execute until after the user has actually entered their details?