<?php

declare(strict_types=1);

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\ImpersonateController;
use App\Http\Controllers\Tenant\IndexController;
use App\Http\Controllers\Auth\VerificationController;
use App\Http\Controllers\Auth\ResetPasswordController;
use App\Http\Controllers\Auth\ForgotPasswordController;
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
use Stancl\Tenancy\Middleware\PreventAccessFromCentralDomains;

/*
|--------------------------------------------------------------------------
| Tenant Routes
|--------------------------------------------------------------------------
|
| Here you can register the tenant routes for your application.
| These routes are loaded by the TenantRouteServiceProvider.
|
| Feel free to customize them however you want. Good luck!
|
*/

Route::middleware([
    'web',
    InitializeTenancyByDomain::class,
    PreventAccessFromCentralDomains::class,
])->group(function () {
    Route::post('password/email', [ForgotPasswordController::class , 'sendResetLinkEmail'])->name('tenant.password.email');
    Route::post('password/reset', [ResetPasswordController::class, 'reset'])->name('tenant.password.update');
  
    Route::get('email/verify/{id}', [VerificationController::class, 'verify'])->name('tenant.verification.verify');
    Route::post('email/resend/{id}',[ VerificationController::class, 'resend'])->name('tenant.verification.resend');
  
    Route::get('/{any}', [IndexController::class, 'index'])->where('any', '.*')->name('tenant.index');

    Route::get('/impersonate/{token}', ImpersonateController::class);
});
