chg: [navigation:socialProvider] Improved UI for SSO profile management

cli-modification-summary
Sami Mokaddem 2022-10-21 14:14:38 +02:00
parent 0f27435251
commit ddfc83af6f
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
4 changed files with 37 additions and 0 deletions

View File

@ -72,6 +72,7 @@ class UsersNavigation extends BaseNavigation
return []; return [];
}); });
if ( if (
!empty($this->loggedUser['social_profile']) &&
!empty(Configure::read('keycloak.enabled')) && !empty(Configure::read('keycloak.enabled')) &&
!empty(Configure::read('keycloak.provider.baseUrl')) && !empty(Configure::read('keycloak.provider.baseUrl')) &&
!empty(Configure::read('keycloak.provider.realm')) && !empty(Configure::read('keycloak.provider.realm')) &&

View File

@ -13,6 +13,11 @@ class SocialProviderHelper extends Helper
'keycloak' => '/img/keycloak_logo.png', 'keycloak' => '/img/keycloak_logo.png',
]; ];
public function hasSocialProfile($identity): bool
{
return !empty($identity['social_profile']);
}
public function getIcon($identity) public function getIcon($identity)
{ {
if (!empty($identity['social_profile'])) { if (!empty($identity['social_profile'])) {

View File

@ -1,5 +1,6 @@
<?php <?php
use Cake\Core\Configure;
use Cake\Routing\Router; use Cake\Routing\Router;
?> ?>
<div class="btn-group"> <div class="btn-group">
@ -29,6 +30,32 @@ use Cake\Routing\Router;
<i class="me-1 <?= $this->FontAwesome->getClass('user-cog') ?>"></i> <i class="me-1 <?= $this->FontAwesome->getClass('user-cog') ?>"></i>
<?= __('Account Settings') ?> <?= __('Account Settings') ?>
</a> </a>
<?php
if (
!empty($this->SocialProvider->hasSocialProfile($this->request->getAttribute('identity'))) &&
!empty(Configure::read('keycloak.enabled')) &&
!empty(Configure::read('keycloak.provider.baseUrl')) &&
!empty(Configure::read('keycloak.provider.realm')) &&
!empty($this->request->getAttribute('identity')['id'])
):
?>
<a
class="dropdown-item"
title="<?= __('Manage SSO account') ?>"
href="<?= sprintf(
'%s/realms/%s/account',
Configure::read('keycloak.provider.baseUrl'),
Configure::read('keycloak.provider.realm')
); ?>"
>
<?php if (!empty($this->SocialProvider->getIcon($this->request->getAttribute('identity')))): ?>
<?= $this->SocialProvider->getIcon($this->request->getAttribute('identity')) ?>
<?php else: ?>
<i class="me-1 <?= $this->FontAwesome->getClass('key') ?>"></i>
<?php endif; ?>
<?= __('SSO Account') ?>
</a>
<?php endif; ?>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item dropdown-item-outline-danger" href="<?= Router::url(['controller' => 'users', 'action' => 'logout', 'plugin' => null]) ?>"> <a class="dropdown-item dropdown-item-outline-danger" href="<?= Router::url(['controller' => 'users', 'action' => 'logout', 'plugin' => null]) ?>">
<i class="me-1 <?= $this->FontAwesome->getClass('sign-out-alt') ?>"></i> <i class="me-1 <?= $this->FontAwesome->getClass('sign-out-alt') ?>"></i>

View File

@ -513,6 +513,10 @@ ul.sidebar-elements > li.category > span.category-divider > hr {
padding: 2px; padding: 2px;
border-radius: 0 0 0 5px; border-radius: 0 0 0 5px;
} }
.header-breadcrumb-children .dropdown-menu .dropdown-item {
display: flex;
align-items: center;
}
.header-breadcrumb-children .dropdown-menu .dropdown-item > i { .header-breadcrumb-children .dropdown-menu .dropdown-item > i {
min-width: 25px; min-width: 25px;
} }