diff --git a/modules/auth/cms_auth_module_i.e b/modules/auth/cms_auth_module_i.e index e03e08e..c44a012 100644 --- a/modules/auth/cms_auth_module_i.e +++ b/modules/auth/cms_auth_module_i.e @@ -69,8 +69,8 @@ feature -- Hooks lnk: CMS_LOCAL_LINK l_destination: READABLE_STRING_8 do - if attached {WSF_STRING} a_response.request.query_parameter ("destination") as p_destination then - l_destination := p_destination.value + if attached {WSF_STRING} a_response.request.item ("destination") as p_destination then + l_destination := p_destination.url_encoded_value else l_destination := a_response.location end @@ -88,4 +88,23 @@ feature -- Hooks end end +feature {NONE} -- Template + + smarty_template_login_block (a_request: WSF_REQUEST; a_module: CMS_MODULE; a_block_id: READABLE_STRING_8; a_cms_api: CMS_API): like smarty_template_block + local + l_destination: detachable READABLE_STRING_32 + do + Result := smarty_template_block (a_module, a_block_id, a_cms_api) + if Result /= Void then + if attached {WSF_STRING} a_request.query_parameter ("destination") as p_destination then + l_destination := p_destination.value + elseif attached {WSF_STRING} a_request.form_parameter ("destination") as p_destination then + l_destination := p_destination.value + end + if l_destination /= Void then + Result.set_value (l_destination, "site_destination") + end + end + end + end diff --git a/modules/auth/cms_authentication_module.e b/modules/auth/cms_authentication_module.e index da6af53..07b4dc6 100644 --- a/modules/auth/cms_authentication_module.e +++ b/modules/auth/cms_authentication_module.e @@ -139,7 +139,7 @@ feature -- Hooks configuration l_url: STRING l_url_name: READABLE_STRING_GENERAL do - if attached {WSF_STRING} a_response.request.query_parameter ("destination") as p_destination then + if attached {WSF_STRING} a_response.request.item ("destination") as p_destination then l_destination := p_destination.value else l_destination := a_response.location @@ -289,7 +289,7 @@ feature -- Handler elseif attached api.module_by_name ("session_auth") then -- FIXME: find better solution to support a default login system. create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) - if attached {WSF_STRING} req.query_parameter ("destination") as l_destination then + if attached {WSF_STRING} req.item ("destination") as l_destination then r.set_redirection ("account/auth/roc-session-login?destination=" + l_destination.url_encoded_value) else r.set_redirection ("account/auth/roc-session-login") @@ -300,7 +300,7 @@ feature -- Handler elseif attached api.module_by_name ("basic_auth") then -- FIXME: find better solution to support a default login system. create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) - if attached {WSF_STRING} req.query_parameter ("destination") as l_destination then + if attached {WSF_STRING} req.item ("destination") as l_destination then r.set_redirection ("account/auth/roc-basic-login?destination=" + l_destination.url_encoded_value) else r.set_redirection ("account/auth/roc-basic-login") diff --git a/modules/basic_auth/cms_basic_auth_module.e b/modules/basic_auth/cms_basic_auth_module.e index 6430e44..a932046 100644 --- a/modules/basic_auth/cms_basic_auth_module.e +++ b/modules/basic_auth/cms_basic_auth_module.e @@ -118,7 +118,7 @@ feature {NONE} -- Implementation: routes r.add_error_message ("You are already signed in!") r.set_main_content (r.link ("Logout", "account/roc-logout", Void)) else - if attached smarty_template_block (Current, "login", api) as l_tpl_block then + if attached smarty_template_login_block (req, Current, "login", api) as l_tpl_block then r.add_javascript_url (r.url ("module/" + name + "/files/js/roc_basic_auth.js", Void)) create vals.make (1) @@ -170,7 +170,7 @@ feature {NONE} -- Block views local vals: CMS_VALUE_TABLE do - if attached smarty_template_block (Current, a_block_id, a_response.api) as l_tpl_block then + if attached smarty_template_login_block (a_response.request, Current, a_block_id, a_response.api) as l_tpl_block then create vals.make (1) -- add the variable to the block a_response.api.hooks.invoke_value_table_alter (vals, a_response) diff --git a/modules/basic_auth/site/templates/block_login.tpl b/modules/basic_auth/site/templates/block_login.tpl index eb3fccf..1b9631d 100644 --- a/modules/basic_auth/site/templates/block_login.tpl +++ b/modules/basic_auth/site/templates/block_login.tpl @@ -4,6 +4,7 @@

Login or Register

+ {unless isempty="$site_destination"}{/unless}
diff --git a/modules/session_auth/cms_session_auth_module.e b/modules/session_auth/cms_session_auth_module.e index 602270e..9b57b59 100644 --- a/modules/session_auth/cms_session_auth_module.e +++ b/modules/session_auth/cms_session_auth_module.e @@ -141,7 +141,7 @@ feature {NONE} -- Implementation: routes if api.user_is_authenticated then r.add_error_message ("You are already signed in!") else - if attached smarty_template_block (Current, "login", api) as l_tpl_block then + if attached smarty_template_login_block (req, Current, "login", api) as l_tpl_block then create vals.make (1) -- add the variable to the block l_tpl_block.set_value (api.user, "user") @@ -216,14 +216,14 @@ feature {NONE} -- Implementation: routes api.record_user_login (l_user) create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) - if attached {WSF_STRING} req.query_parameter ("destination") as p_destination then + if attached {WSF_STRING} req.item ("destination") as p_destination then r.set_redirection (p_destination.url_encoded_value) else r.set_redirection ("") end else create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) - if attached smarty_template_block (Current, "login", api) as l_tpl_block then + if attached smarty_template_login_block (req, Current, "login", api) as l_tpl_block then l_tpl_block.set_value (l_username.value, "username") l_tpl_block.set_value ("Wrong: Username or password ", "error") r.add_block (l_tpl_block, "content") @@ -232,7 +232,7 @@ feature {NONE} -- Implementation: routes r.execute else create {BAD_REQUEST_ERROR_CMS_RESPONSE} r.make (req, res, api) - if attached smarty_template_block (Current, "login", api) as l_tpl_block then + if attached smarty_template_login_block (req, Current, "login", api) as l_tpl_block then if attached {WSF_STRING} req.form_parameter ("username") as l_username then l_tpl_block.set_value (l_username.value, "username") end @@ -272,7 +272,7 @@ feature {NONE} -- Block views local vals: CMS_VALUE_TABLE do - if attached smarty_template_block (Current, a_block_id, a_response.api) as l_tpl_block then + if attached smarty_template_login_block (a_response.request, Current, a_block_id, a_response.api) as l_tpl_block then create vals.make (1) -- add the variable to the block a_response.api.hooks.invoke_value_table_alter (vals, a_response) diff --git a/modules/session_auth/site/templates/block_login.tpl b/modules/session_auth/site/templates/block_login.tpl index 4243ff8..791caa6 100644 --- a/modules/session_auth/site/templates/block_login.tpl +++ b/modules/session_auth/site/templates/block_login.tpl @@ -4,6 +4,7 @@

Login or Register

+ {unless isempty="$site_destination"}{/unless}