Version 3 uses Redirect rules and is meant to work also with social login. I used exactly the rule specified there:
function redirectToConsentForm (user, context, callback) {
var consentGiven = user.user_metadata && user.user_metadata.consentGiven;
// redirect to consent form if user has not yet consented
if (!consentGiven && context.protocol !== 'redirect-callback') {
var auth0Domain = auth0.baseUrl.match(/([^:]*:\/\/)?([^\/]+\.[^\/]+)/)[2];
context.redirect = {
url: configuration.CONSENT_FORM_URL +
(configuration.CONSENT_FORM_URL.indexOf('?') === -1 ? '?' : '&') +
'auth0_domain=' + encodeURIComponent(auth0Domain)
};
}
// if user clicked 'I agree' on the consent form, persist it to their profile
// so they don't get prompted again
if (context.protocol === 'redirect-callback') {
if (context.request.body.confirm === 'yes') {
user.user_metadata = user.user_metadata || {};
user.user_metadata.consentGiven = true;
user.user_metadata.consentTimestamp = Date.now();
auth0.users.updateUserMetadata(user.user_id, user.user_metadata)
.then(function(){
callback(null, user, context);
})
.catch(function(err){
callback(err);
});
} else {
callback(new UnauthorizedError('User did not consent!'));
}
}
callback(null, user, context);
}
and defined CONSENT_FORM_URL as https://wt-peter-auth0_com-0.run.webtask.io/simple-redirect-rule-consent-form
However, when using e.g. google login I get the error message:
code
404
message
“unable to resolve jtn to webtask token”
req_id
“1545052806097.334079”
I can see that the above function is called with reasonable values for user and context.
It seems that I cheered a bit too early. For social logins via facebook and google everything works fine now (consent tracking such, that consent needs only to be given once as intended). However, for database login I now get an “Failed cross origin authentication” error (see below) and I can neither register nor login that way. If I disable the redirect-rule, database login works again, but then I have no more consent tracking.
Perhaps someone can spot the problem in my log message (IDs edited)