Lockscreen
, (*1)
rangoo/lockscreen is Package for Laravel on Packagist, (*2)
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system., (*3)
Installing
composer require rangoo/lockscreen
Help
Lockscreen Middlewares auth.locked
and auth.unlocked
is extended to auth
Middleware, (*4)
auth.locked
middleare means that user must be locked, (*5)
auth.unlocked
middleware means that user must be unlocked, (*6)
Both of them means user must be logged in., (*7)
Examples
Rangoo\Lockscreen\Traits\LockscreenMethods, (*8)
// 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, (*9)
<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, (*10)
<html>
<head>
<script>
window.Lockscreen = {
locked: {{ session()->get('lockscreen', false) }},
route: '{{ url('/lockscreen') }}',
};
</script>
</head>
<body>
<!-- include javascript -->
</body>
</html>
webpack, (*11)
In this example using packages: SensorAFK, axios, (*12)
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');
});
}
});
}
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository., (*13)
Authors
See also the list of contributors who participated in this project., (*16)
License
This project is licensed under the MIT License - see the LICENSE file for details, (*17)