laravel - Laravel 上的 ReCaptcha
问题描述
我在注册控制器中有 ReCaptcha,我想把它放在登录控制器中,比如
<?php
namespace App\Http\Middleware;
use App\Rules\Captcha;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
use App\Rules\Captcha;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
protected function validateLogin(Request $request)
{
$this->validate($request, [
'g-recaptcha-response' => new Captcha(),
]);
}
}
但是我收到一个错误Cannot use App\Rules\Captcha as Captcha because the name is already in use
是否有其他方法可以将 ReCaptcha 放入 reg 和 log 中?
解决方案
您的文件开头有两次以下行:
use App\Rules\Captcha;
推荐阅读
- javascript - Json 数组打印为字符串?不是数组?
- python - 使用 scrapy 抓取特定的 h1 标签
- ruby - Ruby 相当于 Python 的 hash() 是什么?
- css - 以角度为特定垫表设置css样式
- css - React-Bootstrap 基于按钮点击动态定位模态
- python - 夺旗游戏中的一个python问题
- php - 如何在没有 DB 的情况下将 sql 查询更改为 laravel 模型查询
- r - 如何在gridExtra中调整两个具有固定纵横比的ggplots的大小?
- github - 使用 Travis 部署凭据防止任意部署
- android - 将文本输入到 EditText 中的问题