Skip to content

Commit

Permalink
core: store temp rsc id in session for lookup by id (#3468)
Browse files Browse the repository at this point in the history
  • Loading branch information
mworrell committed Jul 5, 2023
1 parent 6a5ee50 commit f7c3507
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions modules/mod_admin/filters/filter_temporary_rsc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ make_rsc({error, notfound}, SessionId, CatId, Props, Context) ->
case m_rsc:insert(Props, Context) of
{ok, RscId} ->
z_session:set({temporary_rsc, CatId}, RscId, Context),
z_session:set({temporary_rsc_id, RscId}, CatId, Context),
spawn_session_monitor(RscId, SessionId, Context),
Args = [
RscId,
Expand Down Expand Up @@ -151,8 +152,22 @@ find_existing(_PageId, _SessionId, CatId, Context) ->
case z_session:get({temporary_rsc, CatId}, Context) of
RscId when is_integer(RscId) ->
case is_unmodified_rsc(RscId, Context) of
true -> {ok, RscId};
false -> {error, notfound}
true ->
UserId = z_acl:user(Context),
CreatorId = m_rsc:p_no_acl(RscId, creator_id, Context),
if
UserId =:= CreatorId ->
{ok, RscId};
true ->
z_session:set({temporary_rsc, CatId}, undefined, Context),
z_session:set({temporary_rsc_id, RscId}, undefined, Context),
m_rsc:delete(RscId, z_acl:sudo(Context)),
{error, notfound}
end;
false ->
z_session:set({temporary_rsc, CatId}, undefined, Context),
z_session:set({temporary_rsc_id, RscId}, undefined, Context),
{error, notfound}
end;
undefined ->
{error, notfound}
Expand Down

0 comments on commit f7c3507

Please sign in to comment.