Bonjour,
J'ai une préoccupation, je développe actuellement une appli en rad server et angular, j'ai créé deux composants cote angular: un pour la création de compte et l'autre pour la connexion, j'ai testé ma fonction connexion que j'ai implémenté en rad server sur Postman et ça marche très bien, cependant, quand je vais sur la page de connexion pour se connecter j'obtiens ces erreurs: Angular Failed to load resource: the server responded with a status of 500 (Internal Server Error) et Rad server {"Thread":22052,"Error":{"Type":"HTTP","Code":"500","Reason":"Error","Error":"","Description":"Violation d'accès à l'adresse 5B0B3DA3 dans le module 'ApiResource.bpl'. Lecture de l'adresse 00000000"}}
Voici le code de la fonction connexion
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 { Fonction permettant à l'utilisateur de se connecter } procedure TUtilisateurResource1.Login(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); var myObject: TJSONObject; userEmail, passcode: string; begin try myObject := ARequest.Body.GetObject; userEmail := myObject.GetValue('email').Value; passcode := myObject.GetValue('mdp').Value; FDQuery1.Close; FDQuery1.SQL.Clear; FDQuery1.SQL.Text := 'SELECT COUNT(*) FROM utilisateur WHERE email = :userEmail'; FDQuery1.ParamByName('userEmail').Value := userEmail; FDQuery1.Open(); if (not FDQuery1.IsEmpty) and (FDQuery1.Fields[0].AsInteger > 0) then begin FDQuery1.Close(); FDQuery1.SQL.Text := 'SELECT COUNT(*) FROM utilisateur WHERE email = :userEmail AND mdp = :passcode'; FDQuery1.ParamByName('userEmail').Value := userEmail; FDQuery1.ParamByName('passcode').Value := passcode; FDQuery1.Open(); if (not FDQuery1.IsEmpty) and (FDQuery1.Fields[0].AsInteger > 0) then begin AResponse.Body.SetValue(TJSONTrue.Create, True); AResponse.StatusCode := 200; end else begin AResponse.Body.SetValue(TJSONFalse.Create, True); AResponse.StatusCode := 401; // Unauthorized end; end else begin AResponse.Body.SetValue(TJSONFalse.Create, True); AResponse.StatusCode := 401; // Unauthorized end; finally FDQuery1.Close(); end; end;
Partager