Skip to content

Commit

Permalink
Added 'acl' option, similar to the acl option of the resource_template.
Browse files Browse the repository at this point in the history
  • Loading branch information
mworrell committed Mar 4, 2011
1 parent 41e9207 commit 185ecd8
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions modules/mod_base/resources/resource_page.erl
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,35 @@ resource_exists(ReqData, Context) ->
is_authorized(ReqData, Context) ->
Context1 = ?WM_REQ(ReqData, Context),
ContextAll = z_context:ensure_all(Context1),
Action = z_context:get(acl_action, ContextAll, view),
z_acl:wm_is_authorized(Action, get_id(ContextAll), ContextAll).
case z_context:get(acl, ContextAll) of
undefined ->
is_authorized_action(ContextAll);
is_auth ->
case z_auth:is_auth(ContextAll) of
true -> is_authorized_action(ContextAll);
false -> z_acl:wm_is_authorized(false, ContextAll)
end;
logoff ->
case z_auth:is_auth(ContextAll) of
true ->
ContextLogoff = z_auth:logoff(ContextAll),
is_authorized_action(ContextLogoff);
false ->
is_authorized_action(ContextAll)
end;
Acl ->
IdCheck = {z_context:get(acl_action, ContextAll, view), get_id(ContextAll)},
z_acl:wm_is_authorized(append_acl(Acl, IdCheck), ContextAll)
end.

is_authorized_action(Context) ->
Action = z_context:get(acl_action, Context, view),
z_acl:wm_is_authorized(Action, get_id(Context), Context).

append_acl(Acl, Action) when is_list(Acl) ->
Acl ++ [Action];
append_acl(Acl, Action) ->
[Acl, Action].


%% @doc Show the page. Add a noindex header when requested by the editor.
Expand Down

0 comments on commit 185ecd8

Please sign in to comment.