Skip to content

Commit

Permalink
Use fail method throughout the Auth class
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Cms/Auth.php
  • Loading branch information
lukasbestle committed Oct 16, 2022
1 parent 922a7ae commit 501fd97
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/Cms/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ class_exists($class) === true &&
}
} catch (Throwable $e) {
// only throw the exception in auth debug mode
if ($this->kirby->option('debug') === true) {
throw $e;
}
$this->fail($e);
}

// always set the email, even if the challenge won't be
Expand Down Expand Up @@ -562,11 +560,7 @@ public function validatePassword(string $email, string $password)

// keep throwing the original error in debug mode,
// otherwise hide it to avoid leaking security-relevant information
if ($this->kirby->option('debug') === true) {
throw $e;
} else {
throw new PermissionException(['key' => 'access.login']);
}
$this->fail($e, new PermissionException(['key' => 'access.login']));
}
}

Expand Down Expand Up @@ -855,13 +849,11 @@ class_exists(static::$challenges[$challenge]) === true &&
// avoid leaking whether the user exists
usleep(random_int(10000, 2000000));

$fallback = new PermissionException(['key' => 'access.code']);

// keep throwing the original error in debug mode,
// otherwise hide it to avoid leaking security-relevant information
if ($this->kirby->option('debug') === true) {
throw $e;
} else {
throw new PermissionException(['key' => 'access.code']);
}
$this->fail($e, $fallback);
}
}

Expand Down

0 comments on commit 501fd97

Please sign in to comment.