[路由:验证。验证] [URI:{locale} / email / verify / {id} / {hash}]缺少必需的参数

时间:2020-02-21 06:35:09

标签: laravel verification

在注册过程中,发送带有{locale}的验证电子邮件时。 数据正在添加到数据库。但是此后,出现以下问题。

缺少[路由:verify.verify] [URI:{locale} / email / verify / {id} / {hash}]所需的参数。

我认为这将是覆盖验证过程的某种类型。

web.php

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());
});

vendor / laravel / framework / src / Illuminate / Routing / Router.php

$this->get('email/verify/{id}/{hash}', 'Auth\VerificationController@verify')->name('verification.verify');

我知道路由器{locale}与路由不匹配。但是如何解决呢?

4 个答案:

答案 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