Search code examples
oracle-databaseplsqloracle-apexoracle12c

Redirect if password is expired in Oracle Apex


I am using Database Account authentication in an app. I want to automatically redirect user to Reset Password Application (it is separate app) if password is expired.

I have created Before Header process which is following

begin
    if instr(owa_util.get_cgi_env('QUERY_STRING'),'&notification_msg=Password%20Expired/') > 0 then
        apex_application.g_unrecoverable_error := true;
        owa_util.redirect_url('http://www.oracle.com');
    end if;
end;

The issue is that notification_msg is not in plain text. It is like below

&notification_msg=UGFzc3dvcmQgRXhwaXJlZDxkaXYga..#moregibberish

Due to this QUERY_STRING is not matched, hence can't redirect. Any suggestion on how could I identify if Password is expired of if I could encode 'Password Expired' (plain notification text) into same as &notification_msg value through code?

Using Apex 21.2 and Database 12c


Solution

  • Resolved through different approach

    1. Created After Header Process in Pre rendering with following code
    declare
        v_count number;
    begin
    
        select count(1)
        into v_count
        from apex_workspace_activity_log
        where application_id = :APP_ID
        and error_on_component_type = 'AUTHENTICATION'
        and error_on_component_name = 'DATABASE ACCOUNT'
        and apex_session_id = :APP_SESSION
        and view_timestamp between systimestamp - interval '2' second and systimestamp  + interval '2' second
        and upper(error_message) like upper('Password Expired (user=' || :P101_USERNAME || ')');
    
        if v_count > 0 then
            apex_application.g_unrecoverable_error := true;
            apex_util.redirect_url(p_url => 'f?p=9999999:1:'||:APP_SESSION);
        end if;  
    end;