Laravel Sentry不是在组表中更新组的权限输入



目前,我正在使用Sentry进行身份验证来审查Laravel项目。每条路线将在Sentry创建的组表中均具有权限。

例如,组中的一行,我正在使用mongodb

{
  "name": "Admins",
  "permissions": "{"task1.create":1,"task1.edit":1,"task1.delete":1}",
  "created_at": ISODate("2015-10-22T01:16:57.118Z"),
  "user_ids": [
    "547c2b5aabb1ce1752318f27",
    "54d82fa1e471f7cf438b4569",
  ]
}

当我在Routes.php中添加新路由时,Sentry未更新组权限

例如,我添加了与task1相同的tast2,我希望组看起来像

{
      "name": "Admins",
      "permissions": "{"task1.create":1,"task1.edit":1,"task1.delete":1,"task2.create":1,"task2.edit":1,"task2.delete":1}",
      "created_at": ISODate("2015-10-22T01:16:57.118Z"),
      "user_ids": [
        "547c2b5aabb1ce1752318f27",
        "54d82fa1e471f7cf438b4569",
      ]
    }

我该怎么做,是否有任何命令或其他可以更新组的表?

您需要手动更新组。您可以创建页面以更新权限。

这是更新组的伪代码。

try
{
    // Find the group using the group id
    $group = Sentry::findGroupById(1);
    // Update the group details
    $group->name = 'Users';
    $group->permissions = array(
        'admin' => 1,
        'users' => 1,
    );
    // Update the group
    if ($group->save())
    {
        // Group information was updated
    }
    else
    {
        // Group information was not updated
    }
}
catch (CartalystSentryGroupsNameRequiredException $e)
{
    echo 'Name field is required';
}
catch (CartalystSentryGroupsGroupExistsException $e)
{
    echo 'Group already exists.';
}
catch (CartalystSentryGroupsGroupNotFoundException $e)
{
    echo 'Group was not found.';
}

有关更多信息,请查看手册:https://cartalyst.com/manual/sentry/2.1#example-8

相关内容

  • 没有找到相关文章

最新更新