Skip to content

Commit

Permalink
Quick implementation of authentication for events
Browse files Browse the repository at this point in the history
Prevent index from handling events if the user is not signed in
to handle session timeouts.
This needs a better fix with some global authentication handler.
  • Loading branch information
AlexanderWingard committed Nov 9, 2010
1 parent a7ea134 commit 8dd683a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions site/src/index.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,23 @@ user() ->
User = umts_db:get_user(wf:user()),
["Signed in as: ", User#users.name, " ", #link{text = "Logout", postback = logout}].

event(logout) ->
event(Event) ->
case wf:user() of
undefined ->
wf:redirect("login");
_ ->
handle_event(Event)
end.

handle_event(logout) ->
wf:logout(),
wf:redirect("login");
event(search) ->
handle_event(search) ->
Request = wf:q(search),
Result = umts_db:autocomplete_card(Request),
Completions = [(card(C))#panel{id = "srch" ++ C#cards.id} || C <- lists:sublist(Result, 10)],
wf:update(searchPanel, [wf:f("Found ~w matching cards", [length(Result)]), Completions]);
event({wtt, Callback, Id}) ->
handle_event({wtt, Callback, Id}) ->
%% TODO: Some more security here?
umts_db:Callback(Id, wf:user()),
Card = card(umts_db:get_card(Id)),
Expand Down

0 comments on commit 8dd683a

Please sign in to comment.