| @@ -9,6 +9,13 @@ namespace ReAct_PME_API.Controllers | |||
| [ApiController] | |||
| public class ChatRoomController(IChatRoomService service, IDT_CONVERSATIONService dt_conversationService, IDT_CONVERSATION_LIGNEService dt_conversation_ligneService, IDT_WORK_FORCEService dt_work_forceService) : ControllerBase | |||
| { | |||
| [HttpGet("llm/test")] | |||
| public async Task<ActionResult> TestRequest() | |||
| { | |||
| await Task.Delay(1); | |||
| return Ok(true); | |||
| } | |||
| [HttpPost("llm")] | |||
| public async Task<ActionResult> EnvoiRequete([FromBody] List<string> requete) | |||
| { | |||
| @@ -11,9 +11,10 @@ | |||
| "DefaultConnection": "Server=SERVER_NAME;Database=ReAct_PME;Trusted_Connection=True;TrustServerCertificate=True" | |||
| }, | |||
| "Jwt": { | |||
| "Issuer": "http://192.168.4.3:7008", // METTRE URL de l'API du SERVEUR | |||
| "Audience": "http://192.168.4.3:7286", // METTRE URL du WebUI du SERVEUR | |||
| "ExpireMinutes": 60 | |||
| "SecretKey": "5357f3ec-0c27-49f6-b68e-28f5c2b260a5", | |||
| "Issuer": "http://192.168.4.3:7008", // METTRE URL de l'API du SERVEUR | |||
| "Audience": "http://192.168.4.3:7286", // METTRE URL du WebUI du SERVEUR | |||
| "ExpireMinutes": 60 | |||
| }, | |||
| "Cors": { | |||
| "AllowedOrigins": [ | |||
| @@ -11,9 +11,10 @@ | |||
| "DefaultConnection": "Server=AIT_GTO_OMEN;Database=ReAct_PME;Trusted_Connection=True;TrustServerCertificate=True" | |||
| }, | |||
| "Jwt": { | |||
| "Issuer": "ReAct_PMEAPI", | |||
| "Audience": "ReAct_PMEClient", | |||
| "ExpireMinutes": 60 | |||
| "SecretKey": "5357f3ec-0c27-49f6-b68e-28f5c2b260a5", | |||
| "Issuer": "ReAct_PMEAPI", | |||
| "Audience": "ReAct_PMEClient", | |||
| "ExpireMinutes": 60 | |||
| }, | |||
| "Cors": { | |||
| "AllowedOrigins": [ | |||
| @@ -2,6 +2,12 @@ | |||
| @inject Blazored.Modal.Services.IModalService ModalService | |||
| @inject AuthenticationStateProvider AuthenticationStateProvider | |||
| @using Microsoft.AspNetCore.Components.Authorization | |||
| @inject HttpClient Http | |||
| @inject ReAct_PME.WebUI.ServicesUI.AuthService AuthService | |||
| @inject NavigationManager Navigation | |||
| @inject IToastService ToastService | |||
| <BlazoredToasts /> | |||
| <div class="page"> | |||
| @@ -153,12 +159,20 @@ | |||
| @code { | |||
| private AuthenticationState? authState; | |||
| private System.Security.Claims.ClaimsPrincipal? user; | |||
| /* | |||
| //private AuthenticationState? authState; | |||
| //private System.Security.Claims.ClaimsPrincipal? user; | |||
| protected override async Task OnInitializedAsync() | |||
| { | |||
| authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); | |||
| user = authState.User; | |||
| var tok = await PagesInitializer.VerifConnexionAndRules(AuthenticationStateProvider, Navigation, Http, ToastService, "api/ChatRoom/llm/test"); | |||
| if (tok == null || tok.Length == 0) | |||
| return; | |||
| else | |||
| AuthService.SetToken(tok); | |||
| //authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); | |||
| //user = authState.User; | |||
| } | |||
| */ | |||
| } | |||
| @@ -5,6 +5,7 @@ | |||
| @inject AuthService AuthService | |||
| @inject AuthenticationStateProvider AuthenticationStateProvider | |||
| @inject NavigationManager Navigation | |||
| @inject IToastService ToastService | |||
| <div class="sidebar @(IsCollapsed ? "collapsed" : "")"> | |||
| <div class="sidebar-header"> | |||
| @@ -187,7 +188,12 @@ | |||
| protected override async Task OnInitializedAsync() | |||
| { | |||
| var id = AuthService.ID; | |||
| var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); | |||
| var user = authState.User; | |||
| var tok = await PagesInitializer.VerifConnexionAndRules(AuthenticationStateProvider, Navigation, Http, ToastService, "api/ChatRoom/llm/test"); | |||
| if (!(tok == null || tok.Length == 0)) | |||
| AuthService.SetToken(tok); | |||
| await LoadChatConversations(); | |||
| @@ -57,7 +57,7 @@ namespace ReAct_PME.WebUI.Pages.ChatRoom | |||
| { | |||
| #region Vérification si utilisateur est connecté et s'il a les droits | |||
| var tok = await PagesInitializer.VerifConnexionAndRules(AuthenticationStateProvider, Navigation, Http, ToastService, "/api/ChatRoom/rag/listeDomaines"); | |||
| var tok = await PagesInitializer.VerifConnexionAndRules(AuthenticationStateProvider, Navigation, Http, ToastService, "/api/ChatRoom/llm/test"); | |||
| if (tok == null || tok.Length == 0) | |||
| return; | |||
| else | |||
| @@ -67,6 +67,13 @@ namespace ReAct_PME.WebUI | |||
| { | |||
| // Vérification si utilisateur est connecté | |||
| var customAuthStateProvider = (CustomAuthenticationStateProvider)authStateprov; | |||
| if (customAuthStateProvider.User == null) | |||
| { | |||
| //navigation.NavigateTo("/login"); | |||
| return ""; | |||
| } | |||
| if (!customAuthStateProvider.User!.Identity!.IsAuthenticated) | |||
| { | |||
| navigation.NavigateTo("/login"); | |||
| @@ -94,8 +101,9 @@ namespace ReAct_PME.WebUI | |||
| return token; | |||
| } | |||
| catch | |||
| catch (Exception ex) | |||
| { | |||
| Console.WriteLine(ex.ToString()); | |||
| navigation.NavigateTo("/login"); | |||
| return ""; | |||
| } | |||