init backend presensi
This commit is contained in:
30
app/Filters/DashboardPageAuthFilter.php
Normal file
30
app/Filters/DashboardPageAuthFilter.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
use App\Modules\Auth\Services\AuthService;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Dashboard Page Auth Filter
|
||||
*
|
||||
* Redirects to /login if user is not logged in (for web dashboard UI).
|
||||
*/
|
||||
class DashboardPageAuthFilter implements \CodeIgniter\Filters\FilterInterface
|
||||
{
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
$authService = new AuthService();
|
||||
if ($authService->currentUser() === null) {
|
||||
return redirect()->to('/login')->with('redirect', uri_string());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
|
||||
{
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user