我对我的应用程序有一个授权方案,该方案首先检查输入的用户名是否是系统中的用户名,然后检查用户是否有权访问此特定应用程序。我遇到的登录问题是用户将登录一次并被拒绝,必须再次登录才能正常工作。我认为问题是::APP_USERNAME不在第一次登录尝试时存储,然后在第二次尝试中存储在应用程序中。我知道必须有一种解决方法,但是我还没有弄清楚。
u_id number := null;
app_id number := null;
auth_id number := null;
authorized number(1,0) := 0;
auth_status char := 'f';
failure_reason varchar2(200) := null;
begin
begin
select id into u_id from user where username=:APP_USERNAME;
exception
when NO_DATA_FOUND then
u_id := null;
failure_reason := 'User not found:' || :APP_USERNAME;
end;
select id into app_id from lkup_application where name='Application Name';
if (u_id is not null) then
begin
select id into auth_id from authorization where application_id = app_id and user_id = u_id;
exception
when NO_DATA_FOUND then
auth_id := null;
failure_reason := 'User not authorized from authorization table.';
end;
end if;
if (auth_id is not null) then
authorized := 1;
auth_status := 's';
end if;
insert into access_audit values(null, :APP_USER, app_id, current_timestamp, auth_status, failure_reason);
commit;
return (authorized = 1);
end;```
答案 0 :(得分:2)
好吧,它是:APP_USER
,而不是:APP_USERNAME
,所以我建议您使用它。