diff --git a/examples/demo/site/modules/auth/templates/block_account_info.tpl b/examples/demo/site/modules/auth/templates/block_account_info.tpl new file mode 100644 index 0000000..debcd47 --- /dev/null +++ b/examples/demo/site/modules/auth/templates/block_account_info.tpl @@ -0,0 +1,62 @@ +
+ {if isset="$user"} +

Account Information

+
+
+
+ {$user.name/} +
+
+ {$user.email/} +
+
+ {$user.creation_date/} +
+
+ {$user.last_login_date/} +
+
+
+ +
+
+
+
+
+ {include file="block_change_password.tpl" /} +
+

Roles

+
+ {foreach item="ic" from="$roles"} +
+
    +
  • + {$ic.name/} +
      +
    • permissions +
        + {foreach item="ip" from="$ic.permissions"} +
      • {$ip/}
      • + {/foreach} +
      +
    • +
    +
  • +
+
+ {/foreach} +
+ + +
+

Profile

+
+ {foreach item="the_value" key="the_name" from="$user.profile"} +
+ {$the_value/} +
+ {/foreach} +
+ + {/if} +
diff --git a/examples/demo/site/modules/auth/templates/block_change_password.tpl b/examples/demo/site/modules/auth/templates/block_change_password.tpl new file mode 100644 index 0000000..dcbe4de --- /dev/null +++ b/examples/demo/site/modules/auth/templates/block_change_password.tpl @@ -0,0 +1,21 @@ +
+
+
+ Change Password Form +
+ + +
+
+ + +
+ + + {if isset="$error_password"} + {$error_password/}
+ {/if} + +
+
+
diff --git a/examples/demo/site/modules/auth/templates/block_post_change.tpl b/examples/demo/site/modules/auth/templates/block_post_change.tpl new file mode 100644 index 0000000..bd80bf3 --- /dev/null +++ b/examples/demo/site/modules/auth/templates/block_post_change.tpl @@ -0,0 +1,3 @@ +
+

You new password has been saved!, Login again

+
diff --git a/modules/auth/cms_authentication_module.e b/modules/auth/cms_authentication_module.e index 5e4ef96..feec514 100644 --- a/modules/auth/cms_authentication_module.e +++ b/modules/auth/cms_authentication_module.e @@ -77,6 +77,7 @@ feature -- Router configure_web (a_api: CMS_API; a_router: WSF_ROUTER) do + a_router.handle ("/account", create {WSF_URI_AGENT_HANDLER}.make (agent handle_account (a_api, ?, ?)), a_router.methods_head_get) a_router.handle ("/account/roc-login", create {WSF_URI_AGENT_HANDLER}.make (agent handle_login (a_api, ?, ?)), a_router.methods_head_get) a_router.handle ("/account/roc-logout", create {WSF_URI_AGENT_HANDLER}.make (agent handle_logout (a_api, ?, ?)), a_router.methods_head_get) a_router.handle ("/account/roc-register", create {WSF_URI_AGENT_HANDLER}.make (agent handle_register (a_api, ?, ?)), a_router.methods_get_post) @@ -84,7 +85,8 @@ feature -- Router a_router.handle ("/account/reactivate", create {WSF_URI_AGENT_HANDLER}.make (agent handle_reactivation (a_api, ?, ?)), a_router.methods_get_post) a_router.handle ("/account/new-password", create {WSF_URI_AGENT_HANDLER}.make (agent handle_new_password (a_api, ?, ?)), a_router.methods_get_post) a_router.handle ("/account/reset-password", create {WSF_URI_AGENT_HANDLER}.make (agent handle_reset_password (a_api, ?, ?)), a_router.methods_get_post) - + a_router.handle ("/account/change-password", create {WSF_URI_AGENT_HANDLER}.make (agent handle_change_password (a_api, ?, ?)), a_router.methods_get_post) + a_router.handle ("/account/post-change-password", create {WSF_URI_AGENT_HANDLER}.make (agent handle_post_change_password (a_api, ?, ?)), a_router.methods_get) end feature -- Hooks configuration @@ -125,6 +127,29 @@ feature -- Hooks configuration feature -- Handler + handle_account (api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE) + local + r: CMS_RESPONSE + do + create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) + r.set_value ("Account Info", "optional_content_type") + + if attached template_block ("account_info", r) as l_tpl_block then + r.set_value (current_user (req), "user") + if attached current_user (req) as l_user then + r.set_value (api.user_api.user_roles (l_user), "roles") + end + r.add_block (l_tpl_block, "content") + else + debug ("cms") + r.add_warning_message ("Error with block [resources_page]") + end + end + r.execute + end + + + handle_login (api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE) local r: CMS_RESPONSE @@ -364,6 +389,51 @@ feature -- Handler r.execute end + handle_change_password (api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE) + local + r: CMS_RESPONSE + l_user_api: CMS_USER_API + do + create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) + l_user_api := api.user_api + + if req.is_post_request_method then + if attached current_user (req) as l_user then + r.set_value (api.user_api.user_roles (l_user), "roles") + if + attached {WSF_STRING} req.form_parameter ("password") as l_password and then + attached {WSF_STRING} req.form_parameter ("confirm_password") as l_confirm_password and then + l_password.value.same_string (l_confirm_password.value) + then + -- Does the passwords match? + l_user.set_password (l_password.value) + l_user_api.update_user (l_user) + r.set_redirection (req.absolute_script_url ("/account/post-change-password")) + else + if attached template_block ("account_info", r) as l_tpl_block then + r.set_value (l_user, "user") + r.values.force ("Passwords Don't Match", "error_password") + r.set_status_code ({HTTP_CONSTANTS}.bad_request) + r.add_block (l_tpl_block, "content") + end + end + end + end + r.execute + end + + handle_post_change_password (api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE) + local + r: CMS_RESPONSE + l_user_api: CMS_USER_API + do + create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) + if attached template_block ("post_change", r) as l_tpl_block then + r.add_block (l_tpl_block, "content") + end + r.execute + end + block_list: ITERABLE [like {CMS_BLOCK}.name] local l_string: STRING diff --git a/modules/auth/site/templates/block_account_info.tpl b/modules/auth/site/templates/block_account_info.tpl new file mode 100644 index 0000000..debcd47 --- /dev/null +++ b/modules/auth/site/templates/block_account_info.tpl @@ -0,0 +1,62 @@ +
+ {if isset="$user"} +

Account Information

+
+
+
+ {$user.name/} +
+
+ {$user.email/} +
+
+ {$user.creation_date/} +
+
+ {$user.last_login_date/} +
+
+
+ +
+
+
+
+
+ {include file="block_change_password.tpl" /} +
+

Roles

+
+ {foreach item="ic" from="$roles"} +
+
    +
  • + {$ic.name/} +
      +
    • permissions +
        + {foreach item="ip" from="$ic.permissions"} +
      • {$ip/}
      • + {/foreach} +
      +
    • +
    +
  • +
+
+ {/foreach} +
+ + +
+

Profile

+
+ {foreach item="the_value" key="the_name" from="$user.profile"} +
+ {$the_value/} +
+ {/foreach} +
+ + {/if} +
diff --git a/modules/auth/site/templates/block_change_password.tpl b/modules/auth/site/templates/block_change_password.tpl new file mode 100644 index 0000000..dcbe4de --- /dev/null +++ b/modules/auth/site/templates/block_change_password.tpl @@ -0,0 +1,21 @@ +
+
+
+ Change Password Form +
+ + +
+
+ + +
+ + + {if isset="$error_password"} + {$error_password/}
+ {/if} + +
+
+
diff --git a/modules/auth/site/templates/block_login.tpl b/modules/auth/site/templates/block_login.tpl index 0549b24..fd24464 100644 --- a/modules/auth/site/templates/block_login.tpl +++ b/modules/auth/site/templates/block_login.tpl @@ -25,10 +25,5 @@

-
- {foreach item="item" from="$oauth_consumers"} - Login with {$item/}
- {/foreach} -
{/unless} diff --git a/modules/auth/site/templates/block_post_change.tpl b/modules/auth/site/templates/block_post_change.tpl new file mode 100644 index 0000000..bd80bf3 --- /dev/null +++ b/modules/auth/site/templates/block_post_change.tpl @@ -0,0 +1,3 @@ +
+

You new password has been saved!, Login again

+
diff --git a/modules/basic_auth/cms_basic_auth_module.e b/modules/basic_auth/cms_basic_auth_module.e index 09fefa3..0034610 100644 --- a/modules/basic_auth/cms_basic_auth_module.e +++ b/modules/basic_auth/cms_basic_auth_module.e @@ -117,6 +117,7 @@ feature -- Hooks if attached current_user (a_response.request) as l_user then a_value.force (l_user, "user") end + a_value.force ("basic_auth_logoff", "strategy") end menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE) diff --git a/modules/basic_auth/site/templates/block_login.tpl b/modules/basic_auth/site/templates/block_login.tpl index a2c142c..285744f 100644 --- a/modules/basic_auth/site/templates/block_login.tpl +++ b/modules/basic_auth/site/templates/block_login.tpl @@ -25,10 +25,5 @@

-
- {foreach item="item" from="$oauth_consumers"} - Login with {$item/}
- {/foreach} -
{/unless} diff --git a/modules/node/cms_node_module.e b/modules/node/cms_node_module.e index 37bb380..4670058 100644 --- a/modules/node/cms_node_module.e +++ b/modules/node/cms_node_module.e @@ -212,11 +212,11 @@ feature -- Hooks menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE) local lnk: CMS_LOCAL_LINK --- perms: detachable ARRAYED_LIST [READABLE_STRING_8] do - create lnk.make ("List of nodes", "nodes") - a_menu_system.primary_menu.extend (lnk) - + debug + create lnk.make ("List of nodes", "nodes") + a_menu_system.primary_menu.extend (lnk) + end create lnk.make ("Trash", "trash") a_menu_system.primary_menu.extend (lnk) diff --git a/modules/oauth20/cms_oauth_20_module.e b/modules/oauth20/cms_oauth_20_module.e index 5611059..f2df195 100644 --- a/modules/oauth20/cms_oauth_20_module.e +++ b/modules/oauth20/cms_oauth_20_module.e @@ -202,6 +202,7 @@ feature -- Hooks if attached current_user (a_response.request) as l_user then a_value.force (l_user, "user") end + a_value.force ("roc-oauth-logout", "strategy") end menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE) diff --git a/modules/openid/cms_openid_module.e b/modules/openid/cms_openid_module.e index dcc0aa1..6ca1c2c 100644 --- a/modules/openid/cms_openid_module.e +++ b/modules/openid/cms_openid_module.e @@ -182,6 +182,7 @@ feature -- Hooks if attached current_user (a_response.request) as l_user then a_value.force (l_user, "user") end + a_value.force ("roc-openid-logout", "strategy") end menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)