Fortify redirect Two-Factor-Challenge with Setup page
Hi
i got the issue that the user is not gettting redirected to the two-factor-challenge page after he confirms which method he wants to get the TOTP code.
if sms email or authentication app after confirmation which method -> the user should get redirected to the two-factor-challenge page
namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Support\Facades\Session;
class TwoFactorController extends Controller { public function setup2FAMethode(Request $request) { // Validierung der Eingabe, sicherstellen, dass eine gültige Methode gewählt wurde $request->validate([ 'totp_methode' => 'required|in:totp,sms,email', ]);
// Speichern der ausgewählten Methode in der Session
session(['selected_totp_method' => $request->input('totp_methode')]);
// Nach der Auswahl den Benutzer zur Two-Factor-Challenge-Seite weiterleiten
return redirect()->route('two-factor.login');
}
}
Route::middleware('auth')->group(function () { // Zwei-Faktor-Setup Route::get('/setup', [TwoFactorController::class, 'setup'])->name('setup');
// Zwei-Faktor-Anmelde-Routen
Route::post('/setup', [TwoFactorController::class, 'setup2FAMethode'])->name('setup2FA.post');
// Fortify's zwei-Faktor-Authentifizierungsseiten
Route::get('/two-factor-challenge', function () {
return view('auth.two-factor-challenge');
})->name('two-factor.challenge');
});
Please or to participate in this conversation.