Feature request: Option to update the window dynamically.
robincsamuel opened this issue · 0 comments
robincsamuel commented
Hi,
I have a use case where the user can choose between an authenticator app or a receiving the OTP through SMS.
I can get the current OTP via the getCurrentOtp
method and text it. However, since it takes a while to deliver the OTP via SMS, I need to set the window to 4
or so. But I still want to keep the window 1
for authenticator app-based requests.
I think it'd be easy to manage if the PragmaRX\Google2FALaravel\Google2FA
uses $this->getWindow()
instead of $this->config('window')
.
I can then use middleware like the one below to update the window.
public function handle($request, Closure $next)
{
$authenticator = app(Authenticator::class)->boot($request);
if(Auth::user()->mfa_preference === Constants::SMS){
$authenticator->setWindow(4);
}
if ($authenticator->isAuthenticated()) {
return $next($request);
}
return $authenticator->makeRequestOneTimePasswordResponse();
}
Please let me know your thoughts, I'd be happy to raise a PR.
Thanks :)