rangoo/lockscreen is Package for Laravel on Packagist
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.
composer require rangoo/lockscreen
Lockscreen Middlewares auth.locked
and auth.unlocked
is extended to auth
Middleware
auth.locked
middleare means that user must be locked
auth.unlocked
middleware means that user must be unlocked
Both of them means user must be logged in.
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
In this example using packages: SensorAFK, axios
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');
});
}
});
}
We use SemVer for versioning. For the versions available, see the tags on this repository.
-
Guja Babunashvili - Initial work - Guja1501
-
Vakho Nakashidze - vakhovakho
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details