This Oracle Apex tutorial will show you how you can redirect the user to a specific page conditionally after log-in.
Suppose you need to redirect the user to the Change Password page after their first login. You can use the following approach.
Oracle Apex – After Login Redirect the User to a Specific Page Example
In Oracle Apex, by default, the user is redirected to the homepage after login. So it is a good idea to create a
Before Header Branch on the homepage and specify a server-side condition to check whether the password has been changed or not after the first login and if not changed, then redirect to the Change Password page.
You can have a field in your user master table or any config table as shown below:
alter table yourUserConfigTable add password_changed varchar2(1) default 'N';
Now you have a field
password_changed with default value
'N' meaning the password has not been changed after the first login. You can set it
Y/N according to your need.
Now open your homepage (page no. 1) and click on the
Pre-Rendering node to expand and under the
Before Header node create a
Branch. As shown in the below image:
Then set the following properties for the Branch:
Page or URL (Redirect)
Page No. to redirect (your change password page)
- Server-side condition > Type:
- Add the following SQL query to the SQL query field:
select 1 from YourUserConfigTable where password_changed = 'N' and username = :app_user
The above branch will only redirect the user if the
password_changed flag is
'N'. After a successful change password, you should update the
change_password flag to
'Y' in your change password page.
To learn how to create a Change Password page, check the following tutorial:
After updating the
password_changed flag to
'Y', the user will be landed on the homepage on their next login.
Similarly, you can create multiple redirects based on multiple server-side conditions. In this case, the different users could be redirected to specific pages.
The above redirect logic will work with any authentication scheme.