Created
March 22, 2019 15:17
-
-
Save Tanver-Hasan/5d6c4270cbb4e95590d7d292f3253823 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function (user, context, callback) { | |
var request = require("request"); | |
var count = context.stats && context.stats.loginsCount ? context.stats.loginsCount : 0; | |
if (count > 1) { | |
return callback(null, user, context); | |
} | |
var headers = { | |
'Authorization': 'Bearer ' + auth0.accessToken, | |
}; | |
const data = { | |
"roles": [ | |
"[role id]" | |
] | |
}; | |
request.post({ | |
url: `https://${auth0.domain}/api/v2/users/${user.user_id}/roles`, | |
headers: headers, | |
json: data | |
}, (err, response, body) => { | |
return callback(new Error("Can not update users with role")); | |
}); | |
callback(null, user, context); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment