【问题标题】:Laravel fortify two factor authentication, enforce confirm code after two factors authentication enabledLaravel 加强双因素身份验证,启用两因素身份验证后强制执行确认代码
【发布时间】:2022-07-25 05:59:50
【问题描述】:

我想要求用户在启用两因素身份验证后输入验证码。

具体来说,当发布/user/two-factor-authentication成功后,二厂开启,此时用户无需提供验证码即可访问资源,所以我想请用户立即确认验证码,但是我没有找到任何关于这个的文档,是否可以实现它?

【问题讨论】:

    标签: laravel fortify two-factor-authentication


    【解决方案1】:

    我已经通过 FortifyServiceProvider.php 中的以下代码接近它

    use Laravel\Fortify\Features;
    use Laravel\Fortify\Actions\AttemptToAuthenticate;
    use Laravel\Fortify\Actions\EnsureLoginIsNotThrottled;
    use Laravel\Fortify\Actions\PrepareAuthenticatedSession;
    use Laravel\Fortify\Actions\RedirectIfTwoFactorAuthenticatable;
    
        Fortify::authenticateThrough(function (Request $request) {
                return array_filter([
                    config('fortify.limiters.login') ? null : EnsureLoginIsNotThrottled::class,
                    Features::enabled(Features::twoFactorAuthentication()) ? RedirectIfTwoFactorAuthenticatable::class : null,
                    AttemptToenter code hereAuthenticate::class,
                    PrepareAuthenticatedSession::class,
                ]);
            });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-09
      • 2020-01-11
      • 2019-07-21
      • 1970-01-01
      • 1970-01-01
      • 2012-11-03
      • 2016-06-06
      • 2016-02-21
      相关资源
      最近更新 更多