-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added JWT middleware and updated services file.
- Loading branch information
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Middlewares; | ||
|
||
use Nur\Auth\Jwt\JwtException; | ||
use Nur\Middleware\Middleware; | ||
|
||
class Jwt extends Middleware | ||
{ | ||
/** | ||
* This method will be triggered | ||
* when the middleware is called | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
try { | ||
auth()->jwt()->check(); | ||
} catch (JwtException $e) { | ||
return response()->json([ | ||
'success' => false, | ||
'error' => $e->getMessage(), | ||
], 401); | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters