• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
Bagisto Forum

Bagisto

  • Register
  • Login
  • Search
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups

Admin user authentication in custom package

General Discussion
3
9
1.3k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P
    ppstech last edited by 15 Jul 2019, 05:38

    I have created a new package and it is linked from admin side menu. Now I want to implement admin user authentication to access the new package. How can I achieve this?

    1 Reply Last reply Reply Quote 0
    • R
      rahul last edited by 15 Jul 2019, 06:57

      Hi,

      We are using ACL for the permisson & you can check it in admin package. (acl.php file in Config folder).
      Now you need to create same file in your package. (Path will be same as admin's acl file have).

      Now you need to merge your acl file with admin's acl file & you can do it in your service provider like this -

              $this->mergeConfigFrom(
                  dirname(__DIR__) . '/Config/acl.php', 'acl'
              );
      

      Now you can create role (https://prnt.sc/of3qj6) and assign that role to specific user.

      Creation of acl file.

      You can create it like below -

      <?php

      return [
      [
      'key' => 'your package's key (generally name of package in small letter',
      'name' => 'name of package',
      'route' => 'route of your package ',
      'sort' => 'sorting order' (integer value for order of appearence)
      ]
      ];

      Thanks

      1 Reply Last reply Reply Quote 0
      • P
        ppstech last edited by 15 Jul 2019, 08:31

        Hi Rahul,
        Thans for your help. I had followed the steps you give. Now I am getting error as in the image shown

         ErrorException (E_ERROR)
        Trying to get property of non-object (View: D:\wamp64\www\bagisto\packages\MyTest\TestTest\src\Resources\views\testtest\create.blade.php)
        

        "Webkul\Admin\src\Providers\AdminServiceProvider.php", This file is highlighted, with these linkes
        $permissionType = auth()->guard('admin')->user()->role->permission_type;
        $allowedPermissions = auth()->guard('admin')->user()->role->permissions;

                protected function composeView()
            
                {
            
                    view()->composer(['admin::layouts.nav-left', 'admin::layouts.nav-aside', 'admin::layouts.tabs'], function ($view) {
            
                        $tree = Tree::create();    
            
                        $permissionType = auth()->guard('admin')->user()->role->permission_type;    
                        $allowedPermissions = auth()->guard('admin')->user()->role->permissions;
            
        

        How to solve this issue?

        1 Reply Last reply Reply Quote 0
        • R
          rahul last edited by 15 Jul 2019, 09:39

          Hi,

          Can you attach a screenshot of your acl file ?

          Thanks

          1 Reply Last reply Reply Quote 0
          • P
            ppstech last edited by 15 Jul 2019, 10:02

            Hi,
            This is my acl file

            <?php
            
            return [
            	[
            	'key' => 'mytest',
            	'name' => 'MyTest',
            	'route' => 'testtest.acl.create',
            	'sort' => '1'
            	]
            ];
            
            1 Reply Last reply Reply Quote 0
            • R
              rahul last edited by 15 Jul 2019, 10:25

              Hi,

              Kindly confirm few things.

              1. Did you created custom role.
              2. Assigned that role to customer.

              If you followed all this steps & still getting this issue then kindly upload your package here, we will solved it.

              Thanks

              1 Reply Last reply Reply Quote 0
              • P
                ppstech last edited by 15 Jul 2019, 10:37

                Hi,
                I have updated the existing role and added my package to the role. The default role is assigned to the admin user.

                1 Reply Last reply Reply Quote 0
                • R
                  rahul last edited by 15 Jul 2019, 10:45

                  Hi,

                  Kindly upload zip of your package with database so that we can check.

                  Thanks

                  K 1 Reply Last reply 24 Feb 2023, 00:32 Reply Quote 0
                  • 4 years later
                  • K
                    Kisdraes @rahul last edited by 24 Feb 2023, 00:32

                    @rahul said in Admin user authentication in custom package:

                    Hi waffle game

                    Kindly upload zip of your package with database so that we can check.

                    Thanks

                    I downloaded the zip code then what should i do

                    1 Reply Last reply Reply Quote 0
                    3 out of 9
                    • First post
                      3/9
                      Last post