Question: Not Able To Save The User Role Permission

Not Able To Save The User Role Permission

I can create a new user role. But when I assign permission, it's giving an error and not able to save changes.

R

Raees

Asked
I can create a new user role. But when I assign permission, it's giving an error and not able to save changes.
  • MS

    Mian Saleem

    Answered
    Hello,

    I have checked the error logs and found that your database has issues. It doesn't have permissions data. Was there any error while installing the item? Please let me know the database access details to that I can confirm.

    Thank you
  • R

    Raees

    Answered
    I didn't have any errors while creating the database and installing the MPS. I again checked the permission in Cpanel and found "All privileges" was checked for the user. Anyway, it's a dev installation, I can reinstall and do it from scratch. I will let you know the fresh installation result.

    Note: I installed another PHP web app in the same host after I installed MPS and its functioning without any issue
  • MS

    Mian Saleem

    Answered
    Hello,

    I am not talking about database or any user permissions. I was talking permissions for the user roles in the MPS. You database as the `permissions` table with all the role permissions data like `read-sales`, `create-sales` ... `update-sales` etc

    We are fixing the reported issue and will release update this Friday.

    Thank you
  • HR

    Hector Rojas

    Answered
    Good night friends, this same error is giving me, it does not assign me the roles and I do not see any errors when performing the installation and neither with the migrations, what can I do to solve it, thank you.
  • MS

    Mian Saleem

    Answered
    **[Hector Rojas](/u/hrojas)** Hello,

    It's due to permissions's guard. I will fix this in coming update.

    If you need it urgently, you can update the `setPermissions` method in `modules/MPS/Http/Controllers/RoleController.php` as following

    ```
    public function setPermissions(Request $request, Role $role)
    {
    $permissions = $request->all();
    $permissions = collect($permissions)->flatten()->all();
    foreach ($permissions as $permission) {
    Permission::updateOrCreate(['name' => $permission]);
    }
    $role->syncPermissions($permissions);
    return response(['success' => true]);
    }
    ```

    Thank you
  • Login to Reply