Skip to content

Commit

Permalink
Rename methods
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoraddatz committed Apr 22, 2024
1 parent 1f2b263 commit 030df84
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Jobs/CreateAndSendLoginCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function handle(): void
{
$columns = config('totp-login.columns');
$notification = config('totp-login.notification');
$code = self::createPin();
$code = self::createCode();

$this->user->{$columns['code']} = Hash::make($code);
$this->user->{$columns['code_valid_until']} = now()->addSeconds(config('totp-login.code.expires_in'));
Expand All @@ -34,7 +34,7 @@ public function handle(): void
/**
* @throws \Exception
*/
public static function createPin(): string
public static function createCode(): string
{
return str_pad(
(string) random_int(0, (int) str_repeat('9', config('totp-login.code.length'))),
Expand Down
8 changes: 4 additions & 4 deletions src/Requests/CodeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public function authenticate(): void
}

$this->ensureIsNotRateLimited();
$this->ensurePinIsNotExpired();
$this->validatePin();
$this->ensureCodeIsNotExpired();
$this->validateCode();

RateLimiter::clear($this->throttleKey());
}
Expand Down Expand Up @@ -88,7 +88,7 @@ public function ensureIsNotRateLimited(): void
/**
* @throws \Illuminate\Validation\ValidationException
*/
public function ensurePinIsNotExpired(): void
public function ensureCodeIsNotExpired(): void
{
if (now() < $this->user->{config('totp-login.columns.code_valid_until')}) {
return;
Expand All @@ -105,7 +105,7 @@ public function ensurePinIsNotExpired(): void
/**
* @throws \Illuminate\Validation\ValidationException
*/
public function validatePin(): void
public function validateCode(): void
{
$this->formatCode();

Expand Down

0 comments on commit 030df84

Please sign in to comment.