Skip to Main Content

APEX

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!

Displaying Custom Messages on Login Page

901881Oct 23 2012 — edited Oct 25 2012
I am using custom authentication with APEX 4.1.1 and I want to display custom error messages on the login page if authentication fails. In my authentication function I'm using apex_util.set_authenication_result to set a result code (code below). I've tried to use the apex_util.get_authenication_result on the login page to hide and show custom messages but it's not working. I don't believe the apex_util.get_authenication_result is actually obtaining the result? Am I doing something wrong? Is there a better way?
FUNCTION verify_user(
    p_username VARCHAR2,
    p_password VARCHAR2
  ) RETURN BOOLEAN
  IS
    v_ctr      NUMBER;
    v_id       NUMBER;
    v_attempts NUMBER;
  BEGIN

    SELECT COUNT(1) INTO v_ctr FROM users_tbl 
       WHERE username = TRIM(UPPER(p_username)) 
       AND password = utl_raw.cast_to_raw(dbms_obfuscation_toolkit.md5(input_string => p_password || TRIM(UPPER(p_username))));

    IF v_ctr = 1 THEN

      SELECT user_id INTO v_id FROM users_tbl WHERE username = TRIM(UPPER(p_username));
      UPDATE users_tbl SET login_attempts = 0 WHERE user_id = v_id;
      APEX_UTIL.SET_AUTHENTICATION_RESULT(0);
      RETURN TRUE;

    ELSE
      SELECT COUNT(1) INTO v_ctr FROM users_tbl WHERE username = TRIM(UPPER(p_username));

      IF v_ctr = 1 THEN

        SELECT user_id INTO v_id FROM users_tbl WHERE username = TRIM(UPPER(p_username));

        SELECT login_attempts INTO v_attempts FROM users_tbl WHERE user_id = v_id;
        IF v_attempts > 5 THEN
          APEX_UTIL.SET_AUTHENTICATION_RESULT(2);
          RETURN FALSE;
        ELSE
          UPDATE users_tbl SET login_attempts = login_attempts + 1 WHERE user_id = v_id;
        END IF;

      END IF;

      APEX_UTIL.SET_AUTHENTICATION_RESULT(1);
      RETURN FALSE;

    END IF;

  END verify_user;
Thanks,
Mark
This post has been answered by jariola on Oct 23 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 22 2012
Added on Oct 23 2012
13 comments
2,317 views