Deb*_*ury 8 php laravel laravel-8
我需要在 Laravel 8 中禁用我的注册路由。试过
Auth::routes([
'register' => false,
'login' => false,
]);
Run Code Online (Sandbox Code Playgroud)
但是应用程序抛出了一个错误。
RuntimeException
In order to use the Auth::routes() method, please install the laravel/ui package.
Run Code Online (Sandbox Code Playgroud)
如果有人指出需要改变的地方,将不胜感激。
谢谢
sta*_*sta 16
Laravel 8 使用强化身份验证。要从您的 Laravel 应用程序禁用注册,您需要从fortify禁用它,它位于/config/fortify.php
'features' => [
// Features::registration(), // disable here
Features::resetPasswords(),
Features::emailVerification(),
Features::updateProfileInformation(),
Features::updatePasswords(),
Features::twoFactorAuthentication(),
],
Run Code Online (Sandbox Code Playgroud)
小智 7
另外,请务必禁用相关路由,在routes/web.php:
Route::get('/register', function() {
return redirect('/login');
});
Route::post('/register', function() {
return redirect('/login');
});
Run Code Online (Sandbox Code Playgroud)
我根据功能测试进行了更改,tests/Feature/RegistrationTest.php以尽量保持工作干净,因此我需要这些重定向。
在我的末尾routes/web.php是以下行:
require __DIR__.'/auth.php';
Run Code Online (Sandbox Code Playgroud)
在routes/auth.php列出了用户登录/注册/注销的所有附加的路由。只需注释掉或/register从那里删除路线。