验证码已失效

This commit is contained in:
邓皓元 2018-12-11 12:00:25 +08:00
parent 43004275ab
commit 834b5cd5a4

View File

@ -7,7 +7,9 @@ use Illuminate\Support\Str;
use Illuminate\Config\Repository;
use Intervention\Image\ImageManager;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Crypt;
use App\Exceptions\NotAllowedException;
use Illuminate\Session\Store as Session;
use Illuminate\Hashing\BcryptHasher as Hasher;
@ -381,7 +383,13 @@ class CaptchaService
*/
public function check($value, $key)
{
return $this->hasher->check($value, $key);
if ($result = $this->hasher->check($value, $key)) {
if (!Cache::add('captcha:'. $key, 1, 30)) {
throw new NotAllowedException('验证码已失效, 请重新获取');
}
}
return $result;
}
/**