0

I am developing an application in rad server and angular, on angular side two forms, one for user registration and the other for login, when I try to login, here is the error I get: Failed to load resource: the server responded with a status of 500 (Internal Server Error) and I can't find out where the error is in my code, I tested the function that allows an alpha user to connect to postman and everything works fine. I emphasize everything works perfectly when I tested my http post method on postman, however, I ignore why this happen, so I need a help

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.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;
  • Please edit your question to include the complete error report starting with the word **traceback**. You can surround the report with 3` before and 3` after to properly format the output. – itprorh66 Jun 21 '23 at 13:32

0 Answers0