Creating Custom Login Screen In Oracle Forms 10g

Below is the example plsql unit to validate login credentials and after successful validation open a new form by passing some parameters to it, in Oracle forms 10g.
Create a form for custom login. Create text items for username and password etc. and a login button. When user click on that login button call this plsql routine.

declare
    vPassword fox_user.password%type; -- get a password field type from your user master table
    plid paramlist;
begin
-- check if username is null
if :appstart.usn is null then
    error_message('User name must be entered.');
    go_item('appstart.usn');
    raise Form_Trigger_Failure;
end if;
-- check if password is null
if :appstart.psw is null then
    error_message('Password must be entered.');
    go_item('appstart.psw');
    raise Form_Trigger_Failure;
end if;
select password into vpassword 
      from fox_user 
      where rtrim(userid) = rtrim(:appstart.usn);
-- decrypt password using your own encrypt / decrypt method.
-- below mentioned decrypt is a program unit i used
if :appstart.psw != decrypt(vpassword) then
     error_message('Invalid Password for the user. Logon Denied!');
     go_item('appstart.psw');
     raise form_trigger_Failure;
end if;
  -- if valid username and password then create parameter list to pass the calling form
    plid := get_parameter_list('formdata');
    if Not id_null(plid) then
         Destroy_parameter_list(plid);
    end if;
    plid := Create_Parameter_list('formdata');
    Add_parameter(plid, 'userid', text_parameter, :appstart.usn);
new_form('main', full_rollback, no_query_only, plid); 
exception
     when no_data_found then
        error_message('Invalid Userid. Please enter valid userid and password. Logon Denied!');
        go_item('appstart.usn');
     when too_many_rows then
        error_message('Internal error...');
     when others then
       null;
end;



 

posted @ 2016-12-25 21:38  全威儒  阅读(417)  评论(0编辑  收藏  举报