Skip to content

Commit

Permalink
Merge tag 'v11.28.1'
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Oct 17, 2024
2 parents cca820d + 2df8eef commit d7a1b75
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
9 changes: 4 additions & 5 deletions Access/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Illuminate\Auth\Access;

use BackedEnum;
use Closure;
use Exception;
use Illuminate\Auth\Access\Events\GateEvaluated;
Expand All @@ -16,6 +15,8 @@
use ReflectionClass;
use ReflectionFunction;

use function Illuminate\Support\enum_value;

class Gate implements GateContract
{
use HandlesAuthorization;
Expand Down Expand Up @@ -200,7 +201,7 @@ protected function authorizeOnDemand($condition, $message, $code, $allowWhenResp
*/
public function define($ability, $callback)
{
$ability = $ability instanceof BackedEnum ? $ability->value : $ability;
$ability = enum_value($ability);

if (is_array($callback) && isset($callback[0]) && is_string($callback[0])) {
$callback = $callback[0].'@'.$callback[1];
Expand Down Expand Up @@ -405,10 +406,8 @@ public function authorize($ability, $arguments = [])
*/
public function inspect($ability, $arguments = [])
{
$ability = $ability instanceof BackedEnum ? $ability->value : $ability;

try {
$result = $this->raw($ability, $arguments);
$result = $this->raw(enum_value($ability), $arguments);

if ($result instanceof Response) {
return $result;
Expand Down
12 changes: 9 additions & 3 deletions DatabaseUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,15 @@ protected function getGenericUser($user)
*/
public function validateCredentials(UserContract $user, #[\SensitiveParameter] array $credentials)
{
return $this->hasher->check(
$credentials['password'], $user->getAuthPassword()
);
if (is_null($plain = $credentials['password'])) {
return false;
}

if (is_null($hashed = $user->getAuthPassword())) {
return false;
}

return $this->hasher->check($plain, $hashed);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion EloquentUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ public function validateCredentials(UserContract $user, #[\SensitiveParameter] a
return false;
}

return $this->hasher->check($plain, $user->getAuthPassword());
if (is_null($hashed = $user->getAuthPassword())) {
return false;
}

return $this->hasher->check($plain, $hashed);
}

/**
Expand Down
7 changes: 3 additions & 4 deletions Middleware/Authorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Illuminate\Auth\Middleware;

use BackedEnum;
use Closure;
use Illuminate\Contracts\Auth\Access\Gate;
use Illuminate\Database\Eloquent\Model;

use function Illuminate\Support\enum_value;

class Authorize
{
/**
Expand Down Expand Up @@ -36,9 +37,7 @@ public function __construct(Gate $gate)
*/
public static function using($ability, ...$models)
{
$ability = $ability instanceof BackedEnum ? $ability->value : $ability;

return static::class.':'.implode(',', [$ability, ...$models]);
return static::class.':'.implode(',', [enum_value($ability), ...$models]);
}

/**
Expand Down

0 comments on commit d7a1b75

Please sign in to comment.