<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| 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('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

Route::post("/login", "App\Http\Controllers\LoginController@login");
Route::post("/pass", "App\Http\Controllers\LoginController@createPasword");
Route::post("/verify-token", "App\Http\Controllers\LoginController@verifyToken");

Route::middleware(['jwt.auth', 'cors'])->group(function(){
    //Módulo de usuarios y perfiles
    Route::post("/create-user", "App\Http\Controllers\UsersProfilesController@createUser");    //F
    Route::post("/delete-user", "App\Http\Controllers\UsersProfilesController@deleteUser");    //F
    Route::post("/modify-user", "App\Http\Controllers\UsersProfilesController@updateUser");    //F
    Route::post("/modify-pass", "App\Http\Controllers\UsersProfilesController@updatePass");    //F
    Route::post("/block-user", "App\Http\Controllers\UsersProfilesController@blockUser");      //F
    Route::post("/modify-profile", "App\Http\Controllers\UsersProfilesController@updateProfile");
    Route::post("/create-profile", "App\Http\Controllers\UsersProfilesController@createProfile");
    Route::post("/delete-profile", "App\Http\Controllers\UsersProfilesController@deleteProfile");
    Route::get("/get-users/{id}/{line}", "App\Http\Controllers\UsersProfilesController@getUsers");         //F
    Route::get("/get-user/{id}/{idUser}/{line}", "App\Http\Controllers\UsersProfilesController@getUser");      //F
    Route::get("/get-profiles/{id}/{line}", "App\Http\Controllers\UsersProfilesController@getProfiles");   //F
    Route::get("/get-profile/{id}/{idUser}/{line}", "App\Http\Controllers\UsersProfilesController@getProfile");//F
    Route::get("/get-modules/{id}/{line}", "App\Http\Controllers\UsersProfilesController@getModules");
    Route::get("/get-submodules/{module}/{id}/{line}", "App\Http\Controllers\UsersProfilesController@getSubmodules");
    Route::get("/get-menus/{module}/{submodule}/{id}/{line}", "App\Http\Controllers\UsersProfilesController@getMenus");
    Route::get("/get-initial-permissions/{id}/{line}", "App\Http\Controllers\UsersProfilesController@buildInitialPermissions");
    //Módulo administrador del sistema
    Route::get("/get-last-connections/{id}/{line}", "App\Http\Controllers\SystemAdministratorController@getLastConnections");
    Route::get("/get-catalogues/{id}/{line}", "App\Http\Controllers\SystemAdministratorController@getCatalogues");
    Route::get("/get-user-connections/{id}/{idUser}/{line}", "App\Http\Controllers\SystemAdministratorController@getUserConnections");
    Route::get("/get-last-actions/{id}/{line}", "App\Http\Controllers\SystemAdministratorController@getLastActions");
    Route::get("/get-user-actions/{id}/{idUser}/{line}", "App\Http\Controllers\SystemAdministratorController@getUserActions");
    Route::post("/set-last-connection", "App\Http\Controllers\SystemAdministratorController@setLastConnection");
    Route::post("/upload-catalogue", "App\Http\Controllers\SystemAdministratorController@registerCatalogue");
});
