-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimplesamlphp_auth_cwl_logout.patch
75 lines (74 loc) · 2.15 KB
/
simplesamlphp_auth_cwl_logout.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
diff --git a/simplesamlphp_auth.module b/simplesamlphp_auth.module
index b888814..a0ca2ba 100644
--- a/simplesamlphp_auth.module
+++ b/simplesamlphp_auth.module
@@ -368,19 +368,36 @@ function simplesaml_auth_user_profile_form_submit(&$form, $form_state) {
* Implements hook_block_view().
*/
function simplesamlphp_auth_block_view($delta = '') {
- if (!_simplesaml_auth_autoload()) {
- // Exit without executing.
- return;
- }
-
- $block = array();
+ global $_simplesamlphp_auth_as;
+ global $user;
+
switch ($delta) {
- case 0:
- $block = array(
- 'subject' => t('simpleSAMLphp login'),
- 'content' => _simplesamlphp_auth_generate_block_text(),
- );
+ case 'original':
+ if (!_simplesamlphp_auth_isEnabled()) {
+ // Exit without executing.
+ return;
+ }
+ else {
+ $block['subject'] = t('simpleSAMLphp login');
+ $block['content'] = _simplesamlphp_auth_generate_block_text();
+ }
break;
+ case 'cwllogout':
+ if (!_simplesamlphp_auth_isEnabled()){
+ // Exit without executing.
+ return;
+ }
+ else {
+ if (!$_simplesamlphp_auth_as->isAuthenticated()) {
+ $block['subject'] = t('CWL Logout Button with dynamic destination argument');
+ $block['content'] = t('not simplesaml authenticated');
+ }
+ else {
+ $block['subject'] = t('CWL Logout Button with dynamic destination argument');
+ $block['content'] = t('simplesaml authenticated');
+ }
+ }
+ break;
}
return $block;
}
@@ -389,13 +406,16 @@ function simplesamlphp_auth_block_view($delta = '') {
* Implements hook_block_info().
*/
function simplesamlphp_auth_block_info() {
- $block = array(
- array(
- 'info' => t('simpleSAMLphp authentication'),
- 'cache' => DRUPAL_NO_CACHE,
- ),
+ $blocks['original'] = array(
+ 'info' => t('simpleSAMLphp authentication'),
+ 'cache' => DRUPAL_NO_CACHE,
);
- return $block;
+
+ $blocks['cwllogout'] = array(
+ 'info' => t('CWL Logout Button'),
+ );
+
+ return $blocks;
}
/****************************************************************************