adamkiss/kirby-impersonate
Composer 安装命令:
composer require adamkiss/kirby-impersonate
包简介
Impersonate users in Kirby CMS Panel
README 文档
README
This plugin allows impersonating users in your panel and/or frontend, by adding a session mark for "user is being impersonated" and then forcibly calling kirby()->impersonate() with the target user.
Installation
composer require adamkiss/kirby-impersonate
As with all Kirby plugins, downloading zip should also work. As should using git submodules, but I never tested that.
Usage
If you want to use this plugin only for your panel debugging, just install it, potentially configure who can impersonate/be impersonated and you're done. If you also want to test different frontend availability, you can change where the admin gets redirect after they start impersonation, and the frontend should just work as if it was the user being impersonated.
For notification about ongoing impersonation, you can use kirby()->user()->isImpersonated(), and you can use the route /__impersonate/stop to stop impersonation. For instance, using following in your template:
<?= kirby()->user()->isImpersonated() ? '<a href="/__impersonate/stop">Stop Impersonation</a>' : ''?>
Configuration
By default, any user with access to users table can impersonate any other user. At the start of the impersonation, window reload happens, and at the end of the impersonation, you'll be redirected to users view in the panel; All of these are configurable via options:
// config.php return [ 'adamkiss.kirby-impersonate' => [ 'can-impersonate' => function () { // who can impersonate? this is a user method, // so "$this" is a user who's checked. // you have access to role, email, uuid… /** @var User $this */ return true; }, 'can-be-impersonated' => function () { // who can be target of impersonation? this is a user method, // so "$this" is a user who's checked // you have access to role, email, uuid… /** @var User $this */ return true; }, // Since the start of redirection is in the users area, null just reloads // You can also use a string to get a URL, or a Closure with the impersonated user // if you need different redirects base on role / email / whatever 'redirect-after-impersonation-start' => null, // Where you're redirected after the impersonation stops // this can be only a string 'redirect-after-impersonation-stop' => kirby()->url('panel') . '/users', ] ];
License
MIT, (c) 2024 Adam Kiss
See LICENSE.md for more information
adamkiss/kirby-impersonate 适用场景与选型建议
adamkiss/kirby-impersonate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 39 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 04 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 adamkiss/kirby-impersonate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 adamkiss/kirby-impersonate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 39
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-26