Added base app

Has basic login UI, has methods to run speedtests
This commit is contained in:
Henry Whitaker
2020-04-08 13:57:26 +01:00
parent e9fdc98fd3
commit 0062ac6960
114 changed files with 120193 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Http\Middleware;
use App\Auth\LoginSession;
use Closure;
use Exception;
class CheckActiveSession
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
try {
$token = $request->bearerToken();
if($token == null) { $token = $request->token; }
$session = LoginSession::where('token', $token)
->first();
if(!$session->active) {
return response()->json([
'error' => 'token is invalid'
], 401);
}
} catch(Exception $e) {
return response()->json([
'error' => 'token not found'
], 401);
}
return $next($request);
}
}