| Server IP : 14.225.216.240 / Your IP : 216.73.216.26 Web Server : nginx/1.20.1 System : Linux localhost.localdomain 5.14.0-596.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jun 27 16:02:33 UTC 2025 x86_64 User : taidh ( 1001) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/pts/app/Middleware/ |
Upload File : |
<?php
//phpcs:ignoreFile
namespace App\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Support\Facades\Route;
/**
* ForcePassword Middleware
*
* @category Class
* @package App\Base\Middleware
* @author Phung, Truong K <fiona.truong@pts-digital.com>
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
* @link https://pts-digital.com
*/
class ForcePassword
{
public function handle(Request $request, Closure $next): Response
{
$route = Route::getRoutes()->match($request);
$currentRoute = $route->getName();
$forceChangePassword = env('FORCE_CHANGE_PASSWORD', 'profile.changePassword');
if (Auth::check()
&& !$request->ajax()
&& (Auth::user()->force_password ?? 0) == 1
&& $forceChangePassword != $currentRoute
) {
return redirect(route($forceChangePassword));
}
return $next($request);
}
}