Guest User

Untitled

a guest
Jul 22nd, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. %%%' HEADER
  2. %%% @author Susan Potter <me@susanpotter.net>
  3. %%% @date 2011-02-16T17:08
  4. %%% @license BSD
  5. %%% @doc Example of a security_handler callback module.
  6. %%% @end
  7. -module(custom_security_handler_callback).
  8.  
  9. -include_lib("nitrogen_core/include/wf.hrl").
  10.  
  11. % security_handler callback exports
  12. -export([authorized/2, login_url/0]).
  13.  
  14. %%%.
  15. %%%' CALLBACKS
  16.  
  17. %% @hidden
  18. authorized(_User, home_page) -> true;
  19. authorized(User, admin_page) -> admin_authorization(User);
  20. authorized(User, _) -> user_authorization(User).
  21.  
  22. %% @hidden
  23. login_path() ->
  24. "/login".
  25.  
  26. %%%.
  27. %%%' PRIVATE FUNCTIONS
  28. %% @private
  29. admin_authorization(User) ->
  30. case User of
  31. "admin" -> true;
  32. _ -> false
  33. end.
  34.  
  35. user_authorization(User) ->
  36. case User of
  37. undefined -> false;
  38. _ -> true
  39. end.
  40. %%%.
  41. %%% vim: set filetype=erlang tabstop=2 foldmarker=%%%',%%%. foldmethod=marker:
Add Comment
Please, Sign In to add comment