Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
8.2k views
in Technique[技术] by (71.8m points)

php - Laravel after login Two factor not working

When I log in after activating two factor, the field where I enter the verification key does not open. Login directly. What could my problem be caused by?

FortifyServiceProvider.php


 public function boot()
    {
        Fortify::createUsersUsing(CreateNewUser::class);
        Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class);
        Fortify::updateUserPasswordsUsing(UpdateUserPassword::class);
        Fortify::resetUserPasswordsUsing(ResetUserPassword::class);

        RateLimiter::for('login', function (Request $request) {
            return Limit::perMinute(5)->by($request->email.$request->ip());
        });

        RateLimiter::for('two-factor', function (Request $request) {
            return Limit::perMinute(5)->by($request->session()->get('login.id'));
        });

        Fortify::confirmPasswordView(function (){
            return view('user.pages.confirm-password');
        });

        Fortify::twoFactorChallengeView(function (){
           return view('user.pages.two-factor-challenge');
        });



    }

fortify.php

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

        Features::twoFactorAuthentication([
            'confirmPassword' => true,
        ]),
    ],

route.php

Route::group(['middleware' => ['auth', 'roles:0'], 'prefix' => 'live'], function () {
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('user.dashboard');

Modals/User.php

namespace AppModels;
use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateFoundationAuthUser as Authenticatable;
use IlluminateNotificationsNotifiable;

use LaravelFortifyTwoFactorAuthenticatable;
class User extends Authenticatable 
{
    use Notifiable;
    use TwoFactorAuthenticatable;



与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...