Skip to content

Commit 061d166

Browse files
committed
attempts expiry with time
1 parent 544d819 commit 061d166

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

lang/en/strings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
'invalid_length' => 'The :attribute must be 7 digits long.',
99
'exists' => 'The :attribute has already been taken.',
1010
'doesnt-exist' => 'The :attribute does not exist.',
11-
'locked' => 'The number is locked due to too many attempts.',
11+
'locked' => 'The number is locked due to too many attempts. You can try again in :time.',
1212
'recently_sent' => 'The code was recently sent to this number. You can try again in :time.'
1313
],
1414
'country_code' => [

src/Models/MobileNumber.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,11 @@ public function getAttemptsExpiryAttribute(): int
320320
return $this->can_request_code ? 0 : $this->attempts_expiry_at->diffInMinutes();
321321
}
322322

323+
public function getAttemptsExpirySecondsAttribute(): int
324+
{
325+
return $this->can_request_code ? 0 : $this->attempts_expiry_at->diffInSeconds();
326+
}
327+
323328
/**
324329
* Verify verification_code
325330
*/

src/Rules/IsValidMobileNumber.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
109109

110110
if ($mobile_number && $this->can_send_otp) {
111111
if (! $mobile_number->can_request_code) {
112-
$fail(trans('mobile-verification::strings.validation.number.locked'));
112+
$attempts_expiry_seconds = seconds_to_human_readable($mobile_number->attempts_expiry_seconds);
113+
$fail(trans('mobile-verification::strings.validation.number.locked', ['time' => $attempts_expiry_seconds]));
113114
}
114115

115116
if ($mobile_number->was_sent_recently) {

0 commit comments

Comments
 (0)