How to redirect editors after login to product list
Forum rules
Always add your Symfony, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Symfony, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
How to redirect editors after login to product list
Hi,
How can only editors be redirected to the product list after logging into the backend? Admins and superadmins should continue to be redirected to the dashboard.
Thank your for your help.
--
aimeos: 2019.10.4
symfony: 4.3
php: 7.2
ubuntu: 18
How can only editors be redirected to the product list after logging into the backend? Admins and superadmins should continue to be redirected to the dashboard.
Thank your for your help.
--
aimeos: 2019.10.4
symfony: 4.3
php: 7.2
ubuntu: 18
Re: How to redirect editors after login to product list
Redirecting admin and editors is done here in the source code:
https://github.com/aimeos/aimeos-symfon ... hp#L33-L47
You can overwrite the controller and the route to make that configurable.
Alternatively, we would also accept a PR that make it configurable based on configuration
https://github.com/aimeos/aimeos-symfon ... hp#L33-L47
You can overwrite the controller and the route to make that configurable.
Alternatively, we would also accept a PR that make it configurable based on configuration
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: How to redirect editors after login to product list
I can do that as soon as I understand Aimeos correctly.
How can I access groups of the user? In the user object I have access to the role as an array (ROLE_ADMIN), but the groups are empty.
How can I access groups of the user? In the user object I have access to the role as an array (ROLE_ADMIN), but the groups are empty.
- Attachments
-
- empty groups.JPG (16.73 KiB) Viewed 207469 times
Re: How to redirect editors after login to product list
You can get the Aimeos groups and use a configuration for the default panel with:
Code: Select all
$config = $context->getConfig();
$custManager = \Aimeos\MShop::create( $context, 'customer' );
foreach( $custManager->getItem( $user->getId(), ['customer/group'] )->getRefItems( 'customer/group' ) as $groupItem )
{
if( ( $panel = $config->get( 'admin/jqadm/panel/' . $groupItem->getCode() ) !== null ) {
$resource = $panel;
}
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: How to redirect editors after login to product list
Many thanks for the help. It works for me.
First I extended the AdminController, get the local object and insert your code in file /src/Controller/MyShopAdminController.php
then I added the new configuration option panel in the file config/packages/aimeos_shop.yaml
and last changed the route in the file config/routes.yaml
First I extended the AdminController, get the local object and insert your code in file /src/Controller/MyShopAdminController.php
Code: Select all
namespace App\Controller;
use Symfony\Component\HttpFoundation\Request;
use Aimeos\ShopBundle\Controller\AdminController;
class MyShopAdminController extends AdminController
{
public function indexAction(Request $request)
{
if ($this->hasRole(['ROLE_ADMIN', 'ROLE_SUPER_ADMIN'])) {
$context = $this->get( 'aimeos.context' )->get(true);
$config = $context->getConfig();
$siteManager = \Aimeos\MShop::create( $context, 'locale/site' );
$user = $this->get( 'security.token_storage' )->getToken()->getUser();
$siteCode = ( $user->getSiteId() ? $siteManager->getItem( $user->getSiteId() )->getCode() : 'default' );
$locale = $user->getLanguageId() ?: ( $this->container->hasParameter( 'locale' ) ? $this->container->getParameter( 'locale' ) : 'en' );
$customerManager = \Aimeos\MShop::create($context, 'customer');
foreach ($customerManager->getItem($user->getId(), ['customer/group'])->getRefItems('customer/group') as $groupItem) {
$resource = $config->get('admin/jqadm/panel/' . $groupItem->getCode()) ?: 'dashboard';
}
$params = array(
'resource' => $resource,
'site' => $request->attributes->get('site', $request->query->get('site', $siteCode)),
'lang' => $request->attributes->get('lang', $request->query->get('lang', $locale)),
);
return $this->redirect($this->generateUrl('aimeos_shop_jqadm_search', $params));
}
Code: Select all
admin:
jqadm:
panel:
editor: product
Code: Select all
aimeos_shop_admin:
path: /admin
controller: App\Controller\MyShopAdminController::indexAction