Added account info, shows basic user info, logout based on login strategy.
Clean block_login.
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<div class="primary-tabs">
|
||||
{if isset="$user"}
|
||||
<h3>Account Information</h3>
|
||||
<div>
|
||||
<div>
|
||||
<div>
|
||||
<label>Username:</label> {$user.name/}
|
||||
</div>
|
||||
<div>
|
||||
<label>Email:</label> {$user.email/}
|
||||
</div>
|
||||
<div>
|
||||
<label>Creation Date:</label> {$user.creation_date/}
|
||||
</div>
|
||||
<div>
|
||||
<label>Last login:</label> {$user.last_login_date/}
|
||||
</div>
|
||||
<div>
|
||||
<form method="get" action="{$site_url/}account/{$strategy/}">
|
||||
<button type="submit">Logout</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<h4>Roles</h4>
|
||||
<div>
|
||||
{foreach item="ic" from="$roles"}
|
||||
<div>
|
||||
<ul>
|
||||
<li>
|
||||
<strong>{$ic.name/}</strong>
|
||||
<ul>
|
||||
<li> <i>permissions</i>
|
||||
<ul>
|
||||
{foreach item="ip" from="$ic.permissions"}
|
||||
<li>{$ip/}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
|
||||
<hr>
|
||||
<h4>Profile</h4>
|
||||
<div>
|
||||
{foreach item="the_value" key="the_name" from="$user.profile"}
|
||||
<div>
|
||||
<label>{$the_name/}:</label> {$the_value/}
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
{/if}
|
||||
</div>
|
||||
@@ -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)
|
||||
@@ -125,6 +126,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
|
||||
|
||||
60
modules/auth/site/templates/block_account_info.tpl
Normal file
60
modules/auth/site/templates/block_account_info.tpl
Normal file
@@ -0,0 +1,60 @@
|
||||
<div class="primary-tabs">
|
||||
{if isset="$user"}
|
||||
<h3>Account Information</h3>
|
||||
<div>
|
||||
<div>
|
||||
<div>
|
||||
<label>Username:</label> {$user.name/}
|
||||
</div>
|
||||
<div>
|
||||
<label>Email:</label> {$user.email/}
|
||||
</div>
|
||||
<div>
|
||||
<label>Creation Date:</label> {$user.creation_date/}
|
||||
</div>
|
||||
<div>
|
||||
<label>Last login:</label> {$user.last_login_date/}
|
||||
</div>
|
||||
<div>
|
||||
<form method="get" action="{$site_url/}account/{$strategy/}">
|
||||
<button type="submit">Logout</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<h4>Roles</h4>
|
||||
<div>
|
||||
{foreach item="ic" from="$roles"}
|
||||
<div>
|
||||
<ul>
|
||||
<li>
|
||||
<strong>{$ic.name/}</strong>
|
||||
<ul>
|
||||
<li> <i>permissions</i>
|
||||
<ul>
|
||||
{foreach item="ip" from="$ic.permissions"}
|
||||
<li>{$ip/}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
|
||||
<hr>
|
||||
<h4>Profile</h4>
|
||||
<div>
|
||||
{foreach item="the_value" key="the_name" from="$user.profile"}
|
||||
<div>
|
||||
<label>{$the_name/}:</label> {$the_value/}
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
{/if}
|
||||
</div>
|
||||
@@ -25,10 +25,5 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
{foreach item="item" from="$oauth_consumers"}
|
||||
<a href="{$site_url/}account/login-with-oauth/{$item/}">Login with {$item/}</a><br>
|
||||
{/foreach}
|
||||
</div>
|
||||
{/unless}
|
||||
</div>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -25,10 +25,5 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
{foreach item="item" from="$oauth_consumers"}
|
||||
<a href="{$site_url/}account/login-with-oauth/{$item/}">Login with {$item/}</a><br>
|
||||
{/foreach}
|
||||
</div>
|
||||
{/unless}
|
||||
</div>
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user