Auth::routes(['register' => false]);在拉拉维尔 8 中不起作用



最近我安装了laravel 8。我正在尝试禁用注册。在laravel 7〃中;Auth::路由(['register'=>false]("这是工作。但是laravel 8不起作用。

你可以试试这个,这对我很有用。将这些路由添加到Auth::routes()的正下方,以覆盖默认的注册路由。对/register路由的任何请求都将重定向到baseUrl。

Route::match(['get', 'post'], 'register', function(){
return redirect('/');
});

要禁用Laravel 8中的注册,请删除Features::registration()行或注释掉app/config/fortify.php文件中的Feature

'features' => [
// Features::registration(),
Features::resetPasswords(),
// Features::emailVerification(),
Features::updateProfileInformation(),
Features::updatePasswords(),
Features::twoFactorAuthentication([
'confirmPassword' => true,
]),
],

适用于Laravel微风。只需在routes/auth.php 中删除或注释这些行

Route::get('/register', [RegisteredUserController::class, 'create'])
->middleware('guest')
->name('register');
Route::post('/register', [RegisteredUserController::class, 'store'])
->middleware('guest');

将其添加到您的路线中

Route::match(['get', 'post'], 'register', function () {
abort(404);
});

相关内容

最新更新