Home > Software engineering >  Multiple Authorization Scheme on one Apex page
Multiple Authorization Scheme on one Apex page

Time:04-25

Apex 20.1

I have an authorization scheme that works fine at the moment, it checks to see if the user is part of the required D365LE and allows them to view relevant pages using the following code:

SELECT 1
FROM USERDETAILS
WHERE D365LE ='GA01' or D365LE = 'GA70'
AND upper(username) = upper(:APP_USER);

I now want users that have the role 'Admin' to be able to view every page, regardless of their D365LE. I tried the following code but it makes any Admin unable to view any page that has the authorization scheme tied to it

SELECT 1
FROM USERDETAILS
WHERE ROLE <> 'Admin'
AND D365LE ='GA01' or D365LE = 'GA70'
AND upper(username) = upper(:APP_USER);

Is there a way I can let admins view every page, regardless of the D365LE whilst keeping users with the role 'Basic' tied to the D365LE authorization scheme?

CodePudding user response:

Something like this, I'd say:

select 1
from userdetails
where upper(username) = upper(:APP_USER)
  and (   (role <> 'Admin' and d365le in ('GA01', 'GA70'))
       or (role = 'Admin')
      );
  • Related