Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: Rename methods [BC] #2

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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