Skip to content

Commit

Permalink
Merge pull request #123 from toplan/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
toplan authored Dec 5, 2016
2 parents fcd2892 + eccd20b commit fb24638
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "toplan/laravel-sms",
"description": "sms send package for laravel",
"license": "MIT",
"version": "2.5.1",
"version": "2.5.2",
"keywords": ["sms", "laravel sms", "laravel-sms"],
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion migrations/2015_12_21_111514_create_sms_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function up()
$table->integer('sent_time')->unsigned()->default(0);

//代理器使用日志记录每个代理器的发送状态可用于排错
$table->text('result_info');
$table->text('result_info')->nullable();

$table->timestamps();
$table->softDeletes();
Expand Down
12 changes: 7 additions & 5 deletions src/Toplan/LaravelSms/validations.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@

Validator::extend('verify_code', function ($attribute, $value) {
$state = SmsManager::retrieveState();
$maxAttempts = config('laravel-sms.verifyCode.maxAttempts', 0);
$attempts = $state['attempts'] + 1;
SmsManager::updateState('attempts', $attempts);
if ($maxAttempts > 0 && $attempts > $maxAttempts) {
return false;
if (isset($state['attempts'])) {
$maxAttempts = config('laravel-sms.verifyCode.maxAttempts', 0);
$attempts = $state['attempts'] + 1;
SmsManager::updateState('attempts', $attempts);
if ($maxAttempts > 0 && $attempts > $maxAttempts) {
return false;
}
}

return $state && $state['deadline'] >= time() && $state['code'] === $value;
Expand Down

0 comments on commit fb24638

Please sign in to comment.