Skip to content

upgradelabs/lockscreen

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lockscreen

Donate Latest Stable Version Total Downloads License

rangoo/lockscreen is Package for Laravel on Packagist

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.

Installing

composer require rangoo/lockscreen

Help

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.

Examples

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');
        });
    }
  });
}

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details