Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. // Role-Based from Template...
  2.  
  3. // This script will step up authentication for any user belonging
  4. // to one of the given roles
  5. // If the user has any of the below roles, authentication will be stepped up
  6. var rolesToStepUp = ['salesmanager'];
  7. var rolesAllowed = ['salesmanager','salesteam'];
  8.  
  9.  
  10. function onLoginRequest(context) {
  11. executeStep(1, {
  12. onSuccess: function (context) {
  13. // Extracting authenticated subject from the first step
  14. var user = context.currentKnownSubject;
  15.  
  16. var hasRole = hasAnyOfTheRoles(user, rolesAllowed);
  17.  
  18. if (!hasRole){
  19. sendError('https://gamage-dev-ed.my.salesforce.com',{'errorcode':'000403','errorMsg':'You are not allowed to login to this app.'});
  20.  
  21. }
  22.  
  23.  
  24. // Checking if the user is assigned to one of the given roles
  25. var hasAdminRole = hasAnyOfTheRoles(user, rolesToStepUp);
  26. if (hasAdminRole) {
  27. Log.info(user.username + ' Has one of Roles: ' + rolesToStepUp.toString());
  28. executeStep(2);
  29. }
  30. }
  31. });
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement