on 12-18-2019 10:28 AM
Hi,
How to get the current logged in user information in sap UI5 deployed in CF?
please help if you know the answer.
Thanks in advance.
I'm not aware that there is a direct way to read the information from the UI5 app.
What you can do, is write a simple server app (or even a FaaS) that reads the JWT token from the request, and returns the information you would like to read. Then, you could call this endpoint from the app.
Here's an example in Java, but it obviously works with nodejs as well.
Please keep in mind: JWT tokens should remain a secret to the user. Do not forward the entire token!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marius Obert,
Thanks for the information.
I am trying to follow this link :- https://blogs.sap.com/2019/05/23/how-to-get-the-email-of-the-logged-in-user-in-cloud-foundry/
If you have any info on above link please let me know.
Thanks,
Poorvi
Hi Nabheet Madan,
I tried the above approach but the proper path is not given in link like where to create these files the proper path to create a file. approuter-start.js and manifest.yml file.
Thanks,
Poorvi
Hi Marius Obert,
I just created a sample MTA project and have added a HTML5 module and inside a HTML5 module added a approuter file now I am trying to call this approuter-start.js file from package.json file but I can see in network tab the approuter-start.js file is not getting called.
I just wants to call this approuter-start.js file from package.json file.
approuter-start.jpg packagejson-file.jpg
Thanks & Regards,
Poorvi
Your code looks correct. Maybe I misunderstood you but I sounded like your app router would be inside the HTML module. In case that right, that explains why it's not being called. The html5 module is most likely the approuter that is serving the UI files. Here is an example that shows an approuter that contains a web app.
If you move your code on this level, it should work.
Hi,
I recently implemented the XSUAA API based on thomas.jung blog post (https://blogs.sap.com/2018/04/23/sap-hana-xsa-controller-api-interaction/) which provided me access to most user login details (in addition to roles etc).
It requires to create a node.js module to be deployed and used by your sapui5 application.
You can check the associated GitHub repo: https://github.com/jungsap/controllerAPI.
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Did you get the correct answer? I have been able to extract the email information of the logged in user but I also need the I-number of the logged in user. If you were able to get that information in CF please let me know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Poorvi,
I was able to fetch the information by using the JWT token forwarded to the backend. To fetch the information in the UI you can follow the below mentioned link and you'll get basic email information.
https://blogs.sap.com/2019/05/23/how-to-get-the-email-of-the-logged-in-user-in-cloud-foundry/
Hi Shivam Aggarwal,
I followed this link that you have shared but the problem is I don't know where to create this approuter-start.js and manifest.json file.
Can you please share some reference project so that i can have a better understanding.
Thanks & Regards,
Poorvi
Hi Poorvi,
You can view the below mentioned project as a sample project for directory structure you might need. The path of approuter to be used is given in package.json of the project you can change that and create the new approuter-start.js as required. approuter-start.js will add this getuserinfo endpoint and keep rest of the functionalities to the default approuter.js provided within the node_modules.
Hi Shivam Aggarwal,
I followed this link https://blogs.sap.com/2019/05/23/how-to-get-the-email-of-the-logged-in-user-in-cloud-foundry/
I am getting this error "/home/vcap/app/node_modules/@sap/approuter/lib/environment.js:19 throw new Error('File not found ' + xsappFile); ^ Error: File not found /home/vcap/app/xs-app.json at Object.getWorkingDirectory (/home/vcap/app/node_modules/@sap/approuter/lib/environment.js:19:13) at Object.module.exports.load (/home/vcap/app/node_modules/@sap/approuter/lib/configuration.js:13:32) at bootstrap (/home/vcap/app/node_modules/@sap/approuter/lib/bootstrap.js:52:36) at Approuter.start (/home/vcap/app/node_modules/@sap/approuter/approuter.js:67:13) at Object.<anonymous> (/home/vcap/app/server.js:45:4) at Module._compile (module.js:653:30) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3) npm ERR! code ELIFECYCLE npm ERR! errno 1"
Do you have any idea about this error in node js.
my application is a multi target application.
Thanks & Regards,
Poorvi
Hi shivam25,
I just created a sample MTA project and here I have created a HTML module and added a approuter file in the same HTML module now I am trying to call this approuter-start.js file from package.json file but I can see in network tab the approuter-start.js file is not getting called.
you have provided me java based solution but I need Node js project for reference.
Thanks & Regards,
Poorvi
Hi poorvijain08 .
You can use the USER API provided by SAP. Please follow the below link.
Regards
Anmol
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anmol Chadha,
Thanks for the answer.
But my application is deployed in Cloud foundry.
It's configuration for NEO environment... it is working for NEO not for CF.
Thanks,
Poorvi
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.