rangoo/lockscreen

此包已被弃用,不再维护。未建议替代包。

在 Laravel 中添加锁屏

v1.0.1 2017-09-09 16:22 UTC

This package is not auto-updated.

Last update: 2023-02-28 20:14:53 UTC


README

Donate Latest Stable Version Total Downloads License

rangoo/lockscreen 是 Laravel 的一个包,可在 Packagist 上找到

入门指南

以下说明将帮助您在本地机器上获取项目的副本并用于开发和测试。有关如何在实时系统上部署项目的说明,请参阅部署部分。

安装

composer require rangoo/lockscreen

帮助

Lockscreen 中间件 auth.lockedauth.unlocked 扩展到 auth 中间件

auth.locked 中间件意味着用户必须被 锁定

auth.unlocked 中间件意味着用户必须被 解锁

两者都意味着用户必须 登录

示例

Rangoo\Lockscreen\Traits\LockscreenMethods

// Controller

use Illuminate\Routing\Controller;
use Rangoo\Lockscreen\Traits\LockscreenMethods;

class LockscreenController extends Controller {
	use LockscreenMethods;
}
// Routes

// Init routes for lockscreen methods
Route::get('/lockscreen', 'LockscreenController@lockscreen')->middleware('auth.locked');
Route::post('/lockscreen', 'LockscreenController@lock')->middleware('auth.unlocked');
Route::delete('/lockscreen', 'LockscreenController@unlock')->middleware('auth.locked');

// If any guard: 'auth.unlocked:guard1,guard2,guard3'
Route::middleware('auth.unlocked')->group(function(){
  // Routes goes here
  // Where must be logged in and unlocked
});

auth.lock blade

<form action="{{ url('/lockscreen') }}" method="post">
   {{ csrf_field() }}
   <h3>{{ auth()->user()->name }}, are you here?</h3>
   <input type="password" name="password"/>
   <input type="submit" value="Unlock" />
</form>

layout blade

<html>
  <head>
    <script>
      window.Lockscreen = {
        locked: {{ session()->get('lockscreen', false) }},
        route: '{{ url('/lockscreen') }}',
      };
    </script>
  </head>
  <body>
    
    <!-- include javascript -->
  </body>
</html>

webpack

在这个示例中,使用了以下包: SensorAFKaxios

const SensorAFK = require('sensor-afk');
const axios = require('axios');

if(!window.Lockscreen.locked){
  new SensorAFK({
    callback: () => {
      axios.post(window.Lockscreen.route)
        .then(() => {
          location.reload();
        })
        .catch(() => {
          alert('something went wrong');
        });
    }
  });
}

版本控制

我们使用 SemVer 进行版本控制。有关可用的版本,请参阅此存储库上的标签

作者

有关参与此项目的贡献者列表,请参阅。

许可

此项目受 MIT 许可证的许可 - 有关详细信息,请参阅LICENSE 文件