This commit is contained in:
33
api/app/Rules/SenhaAtual.php
Normal file
33
api/app/Rules/SenhaAtual.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use App\Models\Cadastro\SujeitoAtencao\Usuario;
|
||||
use Hash;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class SenhaAtual implements Rule
|
||||
{
|
||||
private $id;
|
||||
|
||||
public function __construct($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$usuario = Usuario::findOrFail($this->id);
|
||||
|
||||
if (Hash::check($value, $usuario->senha)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function message()
|
||||
{
|
||||
return 'A nova senha não pode ser igual a senha atual.';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user