Guest User

Untitled

a guest
Dec 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. function TfrmRequestPassword.AuthorizeTechSpecialist(ALogin, APassword: String): Boolean;
  2. var
  3. _Request,
  4. _Response: String;
  5. _Password: String;
  6. D: IXMLDomDocument;
  7. X: IXMLDomNode;
  8. _Str: String;
  9. _ServerConnection: TServerConnection;
  10. begin
  11. Result := False;
  12. _Password := md5(APassword);
  13.  
  14. _Request :=
  15. Format(
  16. '<root> ' +
  17. '<request ' +
  18. // ' region_code="%d" ' +
  19. // ' station_code="%d" ' +
  20. ' login="%s" ' +
  21. ' password="%s" ' +
  22. '/> ' +
  23. '</root>',
  24. [
  25. // GetRegionCode,
  26. // GetPPECode,
  27. ALogin,
  28. _Password
  29. ]);
  30.  
  31. _ServerConnection := TServerConnection.Create();
  32. try
  33. // _ServerConnection.SetProxy(GetSettings().ProxyServer_);
  34. _ServerConnection.SetServerUrl('http://emdelivery.fisgia.prostoy.ru/');
  35.  
  36. _ServerConnection.StartRequest('api/technical-specialist/auth', _Request);
  37. _Response := _ServerConnection.SendRequestAndGetResponse;
  38. if _ServerConnection.Error then begin
  39. // ShowMessage(FederalConnection.StatusLineFormated);
  40. Exit;
  41. end;
  42.  
  43. D := CoDomDocument60.Create;
  44. if D.loadXML(_Response) then begin
  45. X := D.documentElement.selectSingleNode('auth');
  46. if Assigned(X) then begin
  47. Result := AnsiSameText(X.text, 'true');
  48. if Result then begin
  49. X := D.documentElement;
  50. TechSpecialistName := GetXmlNodeValue(X, 'surname') + ' ' +
  51. GetXmlNodeValue(X, 'name') + ' ' +
  52. GetXmlNodeValue(X, 'patronymic');
  53.  
  54. AuthRegionCode := StrToIntDef(GetXmlNodeValue(X, 'region_code'), 0);
  55. AuthStationCode := StrToIntDef(GetXmlNodeValue(X, 'station_code'), 0);
  56. end;
  57. end
  58. else begin
  59. X := D.documentElement.selectSingleNode('//root/Error');
  60. _Str := GetXmlNodeValue(X, '@Code');
  61. if _Str = '28' then begin
  62. // неправильный пароль
  63. ;
  64. end;
  65. end;
  66. end;
  67. finally
  68. _ServerConnection.Free;
  69. end;
  70. end;
Advertisement
Add Comment
Please, Sign In to add comment