Skip to content
Code-Schnipsel Gruppen Projekte
Commit dabb2082 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

fix: user validation before displaying profile bar items

Updated 'getProfileBarCategories.php' to validate user session before displaying profile bar items.
Previously, an error was thrown if a user was not found. Explicitly catching the exception to
ensure a smoother user experience.

Related: order-guestorder#10
Übergeordneter 0e7d27ed
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
2 Merge Requests!69fix: user validation before displaying profile bar items,!67Update 'next-3.x' with latest changes from 'main'
Pipeline-Nr. 16473 bestanden
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
'package_quiqqer_frontend-users_ajax_frontend_profile_getProfileBarCategories', 'package_quiqqer_frontend-users_ajax_frontend_profile_getProfileBarCategories',
function () { function () {
$ProfileSite = Handler::getInstance()->getProfileSite(); $ProfileSite = Handler::getInstance()->getProfileSite();
$User = QUI::getUserBySession();
if (!$ProfileSite) { if (!$ProfileSite) {
return []; return [];
...@@ -32,26 +33,31 @@ function () { ...@@ -32,26 +33,31 @@ function () {
$categories = utils::setUrlsToCategorySettings($categories); $categories = utils::setUrlsToCategorySettings($categories);
// Check if "go to profile" button is added // Check if "go to profile" button is added
try { if (QUI::getUsers()->isUser($User) && !($User instanceof QUI\Users\Nobody)) {
$profileBarSettings = Handler::getInstance()->getProfileBarSettings(); try {
$profileBarSettings = Handler::getInstance()->getProfileBarSettings();
if (!empty($profileBarSettings['showToProfile']) && !empty($categories['user'])) {
array_unshift($categories['user']['items'], [ if (
'name' => 'toprofile', !empty($profileBarSettings['showToProfile'])
'title' => QUI::getLocale()->get( && !empty($categories['user'])
'quiqqer/frontend-users', ) {
'profilebar.to_profile' array_unshift($categories['user']['items'], [
), 'name' => 'toprofile',
'index' => 0, 'title' => QUI::getLocale()->get(
'icon' => 'fa fa-user', 'quiqqer/frontend-users',
'control' => false, 'profilebar.to_profile'
'showinprofilebar' => true, ),
'content' => false, 'index' => 0,
'url' => $ProfileSite->getUrlRewritten() 'icon' => 'fa fa-user',
]); 'control' => false,
'showinprofilebar' => true,
'content' => false,
'url' => $ProfileSite->getUrlRewritten()
]);
}
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
} }
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
} }
return $categories; return $categories;
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren