Create table namely TUSER for holding the user data
CREATE TABLE tuser(
Id NUMBER PRIMARY KEY,
Uname VARCHAR2(24) UNIQUE,
Pwd VARCHAR2(128),
Status VARCHAR2(12)
);
2. Create application item -->> GLOBAL_STATUS_ITEM
3. Custom Authentication Schemes
a. Go to Shared Components/Authentication Schemes then Create
b. Create New Custom Authentication Scheme
* name : my_user_auth * Authentication Function Name: my_user_auth
FUNCTION my_user_auth
(p_username IN VARCHAR2, p_password IN VARCHAR2) RETURN BOOLEAN
AS
Result NUMBER :=0;
Sts VARCHAR2(12);
BEGIN
SELECT 1, status INTO Result, Sts
FROM tuser
WHERE UPPER(uname)=UPPER(p_username)
AND pwd = p_password;
IF Result =1 THEN
APEX_UTIL.SET_SESSION_STATE('GLOBAL_STATUS_ITEM', Sts);
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN FALSE;
END my_user_auth;
4. Create three page blank page with blank region
admin
manager
staff
5. Create branch
Edit Page 1 (Home)
a. Create Branches
b. name : Branch To Function Returning Page
DECLARE
Psts VARCHAR2(64);
Result VARCHAR2(8);
BEGIN
Psts := APEX_UTIL.GET_SESSION_STATE('GLOBAL_STATUS_ITEM');
IF Psts='ADMIN' THEN Result:= '2';
ELSIF Psts='MANAGER' THEN Result:= '3';
ELSE Result:= '4';
END IF;
RETURN Result;
END;
6. check it login
No comments:
Post a Comment