Skip to content

Commit 0ce2778

Browse files
committed
update custom rule
1 parent 8624c43 commit 0ce2778

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

web-assets/auth0/dev-tenant/rules/custom.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function (user, context, callback) {
1919
handle = _.get(user, "nickname", null);
2020
}
2121
console.log("Fetch roles for email/handle: ", user.email, handle, provider);
22+
2223
global.AUTH0_CLAIM_NAMESPACE = "https://" + configuration.DOMAIN + "/";
2324
try {
2425
request.post({
@@ -33,10 +34,12 @@ function (user, context, callback) {
3334
if (response.statusCode !== 200) {
3435
return callback('Login Error: Whoops! Something went wrong. Looks like your registered email has discrepancy with Authentication. Please connect to our support <a href="mailto:support@topcoder.com">support@topcoder.com</a>. Back to application ', user, context);
3536
}
36-
3737
let res = JSON.parse(body);
38+
user.mfa_enabled = res.result.content.mfaEnabled;
39+
user.mfa_verified = res.result.content.mfaVerified;
3840
// TODO need to double sure about multiple result or no result
3941
let userId = res.result.content.id;
42+
user.userId = userId;
4043
let handle = res.result.content.handle;
4144
let roles = res.result.content.roles.map(function (role) {
4245
return role.roleName;
@@ -45,12 +48,12 @@ function (user, context, callback) {
4548

4649
// TEMP
4750
let tcsso = res.result.content.regSource || '';
48-
51+
4952
// block wipro/topgear contractor user
50-
const topgearBlockMessage = 'Topgear can be accessed only by Wipro Employees. If you are a Wipro employee and not able to access, drop an email to <a href="mailto:ask.topgear@wipro.com"> ask.topgear@wipro.com </a> with the error message.Back to application ';
51-
if (roles.indexOf(configuration.TOPGEAR_CONTRACTOR_ROLE) > -1) {
52-
return callback(topgearBlockMessage, user, context);
53-
}
53+
const topgearBlockMessage = 'Topgear can be accessed only by Wipro Employees. If you are a Wipro employee and not able to access, drop an email to <a href=\"mailto:ask.topgear@wipro.com\"> ask.topgear@wipro.com </a> with the error message.Back to application ';
54+
if (roles.indexOf(configuration.TOPGEAR_CONTRACTOR_ROLE) > -1) {
55+
return callback(topgearBlockMessage, user, context);
56+
}
5457

5558
context.idToken[global.AUTH0_CLAIM_NAMESPACE + 'roles'] = roles;
5659
context.idToken[global.AUTH0_CLAIM_NAMESPACE + 'userId'] = userId;

0 commit comments

Comments
 (0)