Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Creating login and authentication in jet 12 project

user525840Aug 29 2022 — edited Aug 29 2022

Hello experts,
I am using oracle jet version 12 quick start nav drawer template for my project.
Now I wish to implement login page and authentication mechanism either using google , OAuth or anything else.
I searched for login on this forum and i came across many related posts but they were of 2017 year which uses oj.router based on jet version 3+ . My jet version is 12 so the same solution does not work for me.
undefined (0 Bytes)undefined (0 Bytes)
Can anyone help guide implementing the same for latest version or divert to specific documentation please?
Regards,
Yogesh

This post has been answered by Philip Sommer on Aug 30 2022
Jump to Answer

Comments

Philip Sommer
Answer

Hi Yogesh,

Take a look at the Cookbook example for the router at https://www.oracle.com/webfolder/technetwork/jet/jetCookbook.html?component=corerouter&demo=module
Setting up the new router should be fairly similar to the old one.
I implemented the login screen in my application as follows. (Don't know if this is best practise, but it works.) This is also very similar to the router example above.
Create a oj-module element in your main/index HTML to switch between login and content screens/modules.
During application startup - e.g. in your root viewmodel constructor - configure the router paths for login and content. Default should be login.
Check the login status of the user. If login is valid, directly navigate to content; Else stay on the login page.
(Optional) If you have more than one content-screen/module you may want to return your user to the one he last visited (if the login is still valid). In this case, I made a simple extension to the OJ CoreRouter which keeps track of the last routing state in the SessionStorage. I then simply restore the cached state.

image.png
Obviously, you will need to change this for the GoogleAPI, e.g. the validateToken() call would need to be replaced/changed.

Kind Regards,
Philip

Marked as Answer by user525840 · Sep 1 2022
John JB Brock-Oracle

As usual, Philip is correct. The CoreRouter is not that much different from the older ojRouter, and the methods used for actual Login integration are the same.

user525840

Thank you John and Philip.
I will try to implement this logic in my application.

1 - 3

Post Details

Added on Aug 29 2022
3 comments
970 views