steveeakin/idle-timeout-alert
Composer 安装命令:
composer require steveeakin/idle-timeout-alert
包简介
A Laravel package for alerting idle sessions about to expire.
README 文档
README
A Laravel package for alerting idle sessions about to expire.
SESSION_LIFETIME is great but how is the user supposed to know when the session is about to expire due to inactivity, especially if it is a low value? Furthermore, a user may be actively engaging the site (by clicking around or filling out a form) without ever sending a request to the backend. Laravel may end the session during this time without the user knowing.
When the session is about to expire, show a dialog so the user can choose not to be logged out.
How it works
This code doesn't actually log the user out. It still relies on Laravel's mechanism for expiring sessions. All it does is periodically check how much time before the session will expire and alert the user when it is almost time.
A demo library is at vectorwyse/idle-timeout-alert-demo
Installation
Laravel package and NPM dependencies
composer require vectorwyse/idle-timeout-alert npm install --save idle-vue
Usage
Disable "Remember Me" functionality
Step 1:
Add the following line to app/User.php:
protected $rememberTokenName = false;
Step 2: Remove the "Remember Me" checkbox from your login form
Publish and compile assets
Step 1: Publish assets to vendor folder:
php artisan vendor:publish --provider="Vectorwyse\IdleTimeoutAlert\IdleTimeoutAlertServiceProvider" --tag="vue-components"
Step 2: Add the following to your application's resources/js/app.js. Place within section where components are registered:
require('./../assets/vendor/vectorwyse/idle-timeout-alert/js/app');
Step 3: Compile
npm run dev
Add component
Finally, add the component to any page where you would like the dialog. A good place is layouts/app.blade.php.
<timeout-dialog></timeout-dialog>
By default the dialog will only appear if the user happens to be idle when the session is about to expire. As long as user has activity, a ping will be sent in the background keeping the session alive.
If you would like to ignore user activity and have the dialog appear no matter what, then use the following:
<timeout-dialog v-bind:ignore-activity="true"></timeout-dialog>
If you want to allow a user to be on a particular page forever without ever timing out, then use the following:
<timeout-dialog v-bind:keep-alive="true"></timeout-dialog>
As long as user is on the page, a ping will be sent in the background keeping the session alive and no dialog will ever appear.
Customization
Feel free to make changes to the dialog in resources/assets/vendor/vectorwyse/idle-timeout-alert/js/components/TimeoutDialog.vue. Don't forget to recompile assets afterward!
Support Us
Vectorwyse is a digital agency offering advisory and web development services. We love building things with Laravel and Vue.js, so when we have an opportunity to give back to the community, we're super excited!
If you find this package useful, or if you would like us to build something for you, feel free to drop us a line!
steveeakin/idle-timeout-alert 适用场景与选型建议
steveeakin/idle-timeout-alert 是一款 基于 Vue 开发的 Composer 扩展包,目前已累计 12.5k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 07 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 steveeakin/idle-timeout-alert 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 steveeakin/idle-timeout-alert 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 12.5k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-11
