Commit a58ea3c5 authored by pjcdawkins's avatar pjcdawkins
Browse files

Issue #2493939: allow admins to view other users' connected accounts

parent cf4f656b
...@@ -49,19 +49,21 @@ function openid_connect_connect_form($form, &$form_state, $account) { ...@@ -49,19 +49,21 @@ function openid_connect_connect_form($form, &$form_state, $account) {
$clients = openid_connect_get_plugins(TRUE); $clients = openid_connect_get_plugins(TRUE);
$read_only = $GLOBALS['user']->uid != $account->uid;
$form['help'] = array( $form['help'] = array(
'#prefix' => '<p class="description">', '#prefix' => '<p class="description">',
'#suffix' => '</p>', '#suffix' => '</p>',
); );
if ($clients) { if (empty($clients)) {
$form['help']['#markup'] = t('You can connect your account with these external providers.');
}
else {
$form['help']['#markup'] = t('No external account providers are available.'); $form['help']['#markup'] = t('No external account providers are available.');
return $form; return $form;
} }
elseif ($GLOBALS['user']->uid == $account->uid) {
$form['help']['#markup'] = t('You can connect your account with these external providers.');
}
$connected_accounts = openid_connect_get_connected_accounts($account); $connected_accounts = openid_connect_get_connected_accounts($account);
...@@ -85,6 +87,7 @@ function openid_connect_connect_form($form, &$form_state, $account) { ...@@ -85,6 +87,7 @@ function openid_connect_connect_form($form, &$form_state, $account) {
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Disconnect from !client_title', array('!client_title' => $client['title'])), '#value' => t('Disconnect from !client_title', array('!client_title' => $client['title'])),
'#name' => 'disconnect__' . $client['name'], '#name' => 'disconnect__' . $client['name'],
'#access' => !$read_only,
); );
} }
else { else {
...@@ -93,6 +96,7 @@ function openid_connect_connect_form($form, &$form_state, $account) { ...@@ -93,6 +96,7 @@ function openid_connect_connect_form($form, &$form_state, $account) {
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Connect with !client_title', array('!client_title' => $client['title'])), '#value' => t('Connect with !client_title', array('!client_title' => $client['title'])),
'#name' => 'connect__' . $client['name'], '#name' => 'connect__' . $client['name'],
'#access' => !$read_only,
); );
} }
} }
......
...@@ -209,6 +209,9 @@ function openid_connect_redirect_access() { ...@@ -209,6 +209,9 @@ function openid_connect_redirect_access() {
*/ */
function openid_connect_connected_accounts_access($account) { function openid_connect_connected_accounts_access($account) {
global $user; global $user;
if (user_access('administer users')) {
return TRUE;
}
return $user->uid && $user->uid === $account->uid && user_access('manage own openid_connect accounts'); return $user->uid && $user->uid === $account->uid && user_access('manage own openid_connect accounts');
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment