<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Modules\Auth\app\Http\Controllers\AuthController;
use Modules\Auth\app\Http\Controllers\ForgotController;
use Modules\Auth\app\Http\Controllers\LoginController;
use Modules\Auth\app\Http\Controllers\RegisterController;
use Modules\Auth\app\Http\Controllers\UserController;

/*
    |--------------------------------------------------------------------------
    | API Routes
    |--------------------------------------------------------------------------
    |
    | Here is where you can register API routes for your application. These
    | routes are loaded by the RouteServiceProvider within a group which
    | is assigned the "api" middleware group. Enjoy building your API!
    |
*/

Route::middleware(['api'])
    ->prefix('v1')
    ->name('api.v1.')
    ->group(function () {
        Route::middleware(['jwt.auth'])->get('users', [UserController::class, 'users']);
        Route::middleware(['jwt.auth'])->post('users/createOrUpdate', [UserController::class, 'createOrUpdate']);
        Route::middleware(['jwt.auth'])->get('users/delete', [UserController::class, 'delete']);
        Route::middleware(['jwt.auth'])->get('users/qrcode/{userId}', [UserController::class, 'qrcode']);

        Route::post('login', [LoginController::class, 'login']);
        Route::middleware(['jwt.auth'])->post('logout', [LoginController::class, 'logout']);
        Route::middleware(['jwt.auth'])->post('change-password', [AuthController::class, 'updatePassword']);
        Route::post('register', [RegisterController::class, 'register']);
        //forgot-password
        Route::post('/send-link', [ForgotController::class, 'sendResetLinkEmail'])->name('admin.forgotPassword.sendLink');
        Route::post('/reset-password', [ForgotController::class, 'updatePassword'])->name('password.update');
        Route::post('/forgot-form', [ForgotController::class, 'showResetForm'])->name('password.reset');
    });
