在注册过程中,发送带有{locale}的验证电子邮件时。 数据正在添加到数据库。但是此后,出现以下问题。
缺少[路由:verify.verify] [URI:{locale} / email / verify / {id} / {hash}]所需的参数。
我认为这将是覆盖验证过程的某种类型。
Route::group([
'prefix' => '{locale}',
'where' => ['locale' => '[a-zA-Z]{2}'],
'middleware' => 'setlocale'], function() {
Auth::routes(['verify' => true]);
Route::get('/home', 'HomeController@index')->name('home');
});
Route::get('/', function () {
return redirect(app()->getLocale());
});
$this->get('email/verify/{id}/{hash}', 'Auth\VerificationController@verify')->name('verification.verify');
我知道路由器{locale}与路由不匹配。但是如何解决呢?
答案 0 :(得分:2)
使用Auth::routes(['verify' => true]);
而不是使用Auth::routes();
并手动添加以下路线:
Route::get('email/verify', 'Auth\VerificationController@show')->name('verification.notice');
Route::get('email/verify/{id}', 'Auth\VerificationController@verify')->name('verification.verify');
Route::get('email/resend', 'Auth\VerificationController@resend')->name('verification.resend');
Route::group([ 'prefix' => '{locale}', 'where' => ['locale' => '[a-zA-Z]{2}'], 'middleware' => 'setlocale'], function() {
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
});
选中SO answer。
答案 1 :(得分:0)
对于Laravel 6和7,verify.verify路线为
'email/verify/{id}/{hash}'
答案 2 :(得分:0)
Laravel 6.0 - Custom email verification: temporarySignedRoute() URL not working with new route
检查一下是否有此内容,因为对我而言这是一个自定义验证链接
答案 3 :(得分:0)
Route::group(['prefix' => '{locale}', 'where' => ['locale' => '[a-zA-Z]{2}'], 'middleware' => 'setlocale'], function() {
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
});
Route::get('email/verify', [App\Http\Controllers\Auth\VerificationController::class,'show'])->name('verification.notice');
Route::get('email/verify/{id}', [App\Http\Controllers\Auth\VerificationController::class,'verify'])->name('verification.verify');
Route::post('email/resend', [App\Http\Controllers\Auth\VerificationController::class,'resend'])->name('verification.resend');
重发应该是Post方法! 这适用于 Laravel 8.0