From 769c14caf8a2680eac9910e8583ec3f025edbc31 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Thu, 16 Jul 2015 15:49:14 +0200 Subject: [PATCH] Display the OAuth association only in "account" page. Improved the template to show only when pertinent. --- .../oauth20/templates/block_account_info.tpl | 14 +++++++------- modules/oauth20/cms_oauth_20_module.e | 6 ++++-- .../oauth20/site/templates/block_account_info.tpl | 14 +++++++------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/examples/demo/site/modules/oauth20/templates/block_account_info.tpl b/examples/demo/site/modules/oauth20/templates/block_account_info.tpl index 025c463..4a4c7ef 100644 --- a/examples/demo/site/modules/oauth20/templates/block_account_info.tpl +++ b/examples/demo/site/modules/oauth20/templates/block_account_info.tpl @@ -1,12 +1,11 @@
+ {unless isempty="$oauth_associated"}

Un-Associate Account with Oauth Consumer

{foreach item="consumer" from="$oauth_associated"}
-
- -
+
@@ -14,14 +13,14 @@
{/foreach}
+ {/unless} + {unless isempty="$oauth_not_associated"}

Associate Account with Oauth Consumer

{foreach item="consumer" from="$oauth_not_associated"}
-
- -
+
@@ -29,4 +28,5 @@
{/foreach} -
\ No newline at end of file +
+ {/unless} diff --git a/modules/oauth20/cms_oauth_20_module.e b/modules/oauth20/cms_oauth_20_module.e index 3c6b105..7116dfd 100644 --- a/modules/oauth20/cms_oauth_20_module.e +++ b/modules/oauth20/cms_oauth_20_module.e @@ -266,10 +266,12 @@ feature -- Hooks a_response.location.starts_with ("account/roc-oauth-login") then get_block_view_login (a_block_id, a_response) - elseif a_block_id.is_case_insensitive_equal_general ("account") then + elseif a_block_id.is_case_insensitive_equal_general ("account") and then + a_response.location.same_string ("account") + then if attached template_block ("account_info", a_response) as l_tpl_block and then - attached current_user (a_response.request) as l_user + attached a_response.user as l_user then associate_account (l_user, a_response.values) a_response.add_block (l_tpl_block, "content") diff --git a/modules/oauth20/site/templates/block_account_info.tpl b/modules/oauth20/site/templates/block_account_info.tpl index 025c463..4a4c7ef 100644 --- a/modules/oauth20/site/templates/block_account_info.tpl +++ b/modules/oauth20/site/templates/block_account_info.tpl @@ -1,12 +1,11 @@
+ {unless isempty="$oauth_associated"}

Un-Associate Account with Oauth Consumer

{foreach item="consumer" from="$oauth_associated"}
-
- -
+
@@ -14,14 +13,14 @@
{/foreach}
+ {/unless} + {unless isempty="$oauth_not_associated"}

Associate Account with Oauth Consumer

{foreach item="consumer" from="$oauth_not_associated"}
-
- -
+
@@ -29,4 +28,5 @@
{/foreach} -
\ No newline at end of file +
+ {/unless}