Adicao de middleware de validacao de senha
parent
3739cfa5b8
commit
89a0f9e89d
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Pablo\Ae3auth\app\Http;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Exceptions\HttpResponseException;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class InvalidPasswordMiddleware
|
||||
{
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if (auth()->check()) {
|
||||
if (auth()->user()->passwordExpired()) {
|
||||
throw new HttpResponseException(
|
||||
response()->json([
|
||||
'message' => __('auth.password_expired'),
|
||||
], Response::HTTP_FORBIDDEN)
|
||||
);
|
||||
}
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Pablo\Ae3auth\app\Traits;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
trait HasPasswordValidation
|
||||
{
|
||||
public function passwordExpired()
|
||||
{
|
||||
$passwordExpiresAtColumn = config('ae3auth-config.user.expires_password_column_name');
|
||||
return Carbon::now()->greaterThan($this->$passwordExpiresAtColumn);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue