Search code examples
oracleoracle-apex-19.1

Oracle apex functionality to send users option to set password


I am developing a ticketing application and using custom authentication using below function.

create or replace FUNCTION f_val_leave_user_issue(p_username IN VARCHAR2,
                                            p_password IN VARCHAR2)
  RETURN BOOLEAN IS
  lv_char CHAR(1);
  lv_cnt NUMBER;
BEGIN
  SELECT 'x'
  INTO   lv_char
  FROM   p_it_people
  WHERE  upper(p_username) = upper(person_username)
  AND    p_password = person_password;
  apex_util.set_authentication_result(0);
  RETURN TRUE;

EXCEPTION
  WHEN OTHERS THEN
    apex_util.set_authentication_result(4);
    RETURN FALSE;
END f_val_leave_user_issue;

As of now it takes username and password from p_it_people table, which i use in my login page.

Can i customize it further so that whenever there is a new user created in p_it_people, that user is prompted to set his own password and after setting,that password is automatically stored in p_it_people table??


Solution

  • You need to make sure not to save passwords in the database as clear text. I recommend reading this blog post: https://blogs.oracle.com/apex/custom-authentication-and-authorization-using-built-in-apex-access-control-a-how-to

    You only save the hash value of the password in the database and every time a user login you need to hash their password and compare the two hashes.

    Resetting the password is simply allowing the end-user to change his saved hash password.