initial commit
This commit is contained in:
36
app/Http/Middleware/PatientAuth.php
Normal file
36
app/Http/Middleware/PatientAuth.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use App\Model\ProcessLog;
|
||||
use Carbon\Carbon;
|
||||
use App\Classes\Constant;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use App\Model\Client;
|
||||
use App\Model\JsToken;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\User;
|
||||
|
||||
class PatientAuth
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
Auth::setDefaultDriver('patient');
|
||||
if (!Auth::guard('patient')->check()) {
|
||||
// If not authenticated, return unauthorized response
|
||||
return response()->json([
|
||||
'message' => 'Unauthorized'
|
||||
], 401);
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user