Create Custom User Authorization Scheme In Oracle Apex.
Part-1
Custom User Authorization Scheme I Have Tried To Show Through A Few Episodes For The Sake Of Simplicity And Explanation. Hopefully, If You Follow All The Videos And Posts, You Will Get User Authorization.
CREATE TABLE "MY_USERS"
( "USER_ID" NUMBER,
"USERNAME" VARCHAR2(50),
"FULL_NAME" VARCHAR2(100),
"PHONE_NUMBER" NUMBER,
"EMAIL_ADDRESS" VARCHAR2(50),
"IMAGE" BLOB,
"USER_TYPE" VARCHAR2(250),
"SHOP_CATEGORY" VARCHAR2(100),
"IS_ACTIVE" VARCHAR2(10),
"PASSWORD" VARCHAR2(50),
"CREATE_BY" VARCHAR2(50),
"ADDED_DATE" DATE,
"UPDATE_DATE" DATE,
"MIME_TYPE" VARCHAR2(250),
"PIN" VARCHAR2(4000),
"UPDATE_BY" VARCHAR2(250),
"PASSWORD_RECOVERY_CODE" VARCHAR2(150),
"FORGOT_PASSWORD_USE" VARCHAR2(150),
"WRONG_PASS_ALLOW" NUMBER,
"UNLOCK_TIME" DATE,
"PP_URL" VARCHAR2(4000),
"PID_EMPLOYEE" NUMBER,
"GENDER" VARCHAR2(255),
CONSTRAINT "MY_USERS_PK" PRIMARY KEY ("USER_ID")
USING INDEX ENABLE,
CONSTRAINT "MY_USERNAME_CON" UNIQUE ("USERNAME")
USING INDEX ENABLE
)
/
CREATE OR REPLACE EDITIONABLE TRIGGER "BI_MY_USERS"
BEFORE INSERT
ON "MY_USERS"
FOR EACH ROW
BEGIN
IF :NEW."USER_ID" IS NULL
THEN
SELECT "MY_USERS_SEQ".NEXTVAL INTO :NEW."USER_ID" FROM sys.DUAL;
END IF;
END;
/
ALTER TRIGGER "BI_MY_USERS" ENABLE
/
CREATE OR REPLACE EDITIONABLE TRIGGER "PIN_MY_USER"
BEFORE INSERT OR UPDATE OF PASSWORD
ON MY_USERS
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW
DECLARE
BEGIN
:new.PIN := USER_AUTH.CUSTOM_HASH (:new.USER_ID, :new.PASSWORD);
IF INSERTING
THEN
:NEW.ADDED_DATE := SYSDATE;
ELSIF UPDATING
THEN
:NEW.UPDATE_DATE := SYSDATE;
END IF;
EXCEPTION
WHEN OTHERS
THEN
RAISE;
END;
/
ALTER TRIGGER "PIN_MY_USER" ENABLE
/
CREATE OR REPLACE EDITIONABLE TRIGGER "USER_TABLE_DETELS"
before insert or update on MY_USERS
for each row
begin
if inserting then
:new.ADDED_DATE := localtimestamp;
:new.CREATE_BY := nvl(sys_context('APEX$SESSION','APP_USER'),user);
end if;
:new.UPDATE_DATE := localtimestamp;
:new.UPDATE_BY := nvl(sys_context('APEX$SESSION','APP_USER'),user);
end USER_TABLE_DETELS;
/
ALTER TRIGGER "USER_TABLE_DETELS" ENABLE
/
Authorization or Authentication?
ReplyDeleteHELLO SIR
Delete