Hi,
I'm working away on my first Chicagoboss demo application, and I'm trying
to implement an identification, authorization, access workflow.
------------------------------
I started by implementing a controller_filter:
-module(training_filter).
-export([before_filter/2]).
before_filter(_FilterConfig, RequestContext) ->
SessionId = proplists:get_value(session_id, RequestContext),
%% Request = proplists:get_value(request, RequestContext),
lager:log(info, self(), " before filter invoked", []),
Action = proplists:get_value(action, RequestContext),
case boss_session:get_session_data(SessionId, username) of
undefined when Action == "login" ->
{ok, RequestContext};
undefined ->
lager:log(error, self(), " failed to grab user from
session/RequestContext ~p", [RequestContext]),
boss_session:set_session_data(SessionId, original_request_context,
RequestContext),
{redirect, "/login"}
end.
------------------------------
I then implemented a (laughably) trivial login module:
-module(training_security_controller, [Req, SessionID]).
-compile(export_all).
login('POST', []) ->
User = Req:post_param("username"),
Password = Req:post_param("password"),
lager:log(info, self(), "~p ~p", [User, Password]),
case Password of
"foo" ->
boss_session:set_session_data(SessionID, username, User),
OriginalRequestContext = boss_session:get_session_data(SessionID,
original_request_context),
%but I really want to replay the original request
{redirect, "/"}
;
_ ->
boss_flash:add(SessionID, notice, "Login", "Bad credentials, try again!"),
{ok, login}
end
;
login('GET', []) ->
boss_flash:add(SessionID, notice, "Login", "Enter your password!"),
{ok, login}.
What I would like to do is call the originally requested controller, with
the OriginalRequestContext taken from the session, and let it handle the
return/output.
Is such a thing possible ? I've done some digging but can't find any
relevant examples.
Thanks,
Bryan
--
You received this message because you are subscribed to the Google Groups
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit
https://groups.google.com/d/msgid/chicagoboss/4849cdf5-b054-459c-ad05-7b3d26a18ad6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.