cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to fetch logged in user role on BTP launchpad thought SAP UI5 application

vishalkumar1305
Explorer

Hello Experts,

How we can fetch Roles from SAP UI5 application deployed in cloud foundry?

Currently , I am working on SAPUI5 application, where I have to manage my data on the basis of the launchpad roles of logged in user.

Please help me if you have knowledge on this.

0 Kudos

I am also interested in the answer to this question.

Rakesh_Kr
Participant
0 Kudos

Hi Vishal,

Check this out, the first comment in this blog seems relevant to what you are implementing.

SAP Tech Bytes: Approuter User API Service | SAP Blogs

/Rakesh

View Entire Topic
nicoschoenteich
Developer Advocate
Developer Advocate
0 Kudos

Thanks Rakesh for the link. That is absolutely right. To get the roles you need a bit of custom code (unfortunately). To specify it a little further:

Using the node.js based approtuer you can add the custom code in a file on root level of the approtuer (next to the xs-app.json, package.json) and then point the start script of the approuter (in package.json) to that file instead of the standard approuter.js in the node_module. Then you can call "/me" from within you app to get the user info.

Hope this helps.

Thiagoc789
Participant
0 Kudos

I have been following the tutorial and I have created the file called middle.js in which part of my package.json should I configure it to be executed when opening my sapui5 application deployed in workzone launchpad?

nicoschoenteich
Developer Advocate
Developer Advocate
0 Kudos

Hi Santiago,

the custom middleware scenario works with the standalone approuter, but not with the managed approuter that you rely on when deploying your UI5 apps to SAP Build Work Zone. But you can always restrict user access through the "scope" property in your xs-app.json routing configuration file.

I realize that this answers contradicts with my previous one. To be honest I think I didn't read the question right the first time...

Thiagoc789
Participant
0 Kudos

can you help me on this question please, i want to restrict access to my views in sapui5 not in CAP. Thanks
https://answers.sap.com/questions/13950708/get-the-roles-of-the-logged-in-user-in-my-sapui5-a.html