Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TfrmRequestPassword.AuthorizeTechSpecialist(ALogin, APassword: String): Boolean;
- var
- _Request,
- _Response: String;
- _Password: String;
- D: IXMLDomDocument;
- X: IXMLDomNode;
- _Str: String;
- _ServerConnection: TServerConnection;
- begin
- Result := False;
- _Password := md5(APassword);
- _Request :=
- Format(
- '<root> ' +
- '<request ' +
- // ' region_code="%d" ' +
- // ' station_code="%d" ' +
- ' login="%s" ' +
- ' password="%s" ' +
- '/> ' +
- '</root>',
- [
- // GetRegionCode,
- // GetPPECode,
- ALogin,
- _Password
- ]);
- _ServerConnection := TServerConnection.Create();
- try
- // _ServerConnection.SetProxy(GetSettings().ProxyServer_);
- _ServerConnection.SetServerUrl('http://emdelivery.fisgia.prostoy.ru/');
- _ServerConnection.StartRequest('api/technical-specialist/auth', _Request);
- _Response := _ServerConnection.SendRequestAndGetResponse;
- if _ServerConnection.Error then begin
- // ShowMessage(FederalConnection.StatusLineFormated);
- Exit;
- end;
- D := CoDomDocument60.Create;
- if D.loadXML(_Response) then begin
- X := D.documentElement.selectSingleNode('auth');
- if Assigned(X) then begin
- Result := AnsiSameText(X.text, 'true');
- if Result then begin
- X := D.documentElement;
- TechSpecialistName := GetXmlNodeValue(X, 'surname') + ' ' +
- GetXmlNodeValue(X, 'name') + ' ' +
- GetXmlNodeValue(X, 'patronymic');
- AuthRegionCode := StrToIntDef(GetXmlNodeValue(X, 'region_code'), 0);
- AuthStationCode := StrToIntDef(GetXmlNodeValue(X, 'station_code'), 0);
- end;
- end
- else begin
- X := D.documentElement.selectSingleNode('//root/Error');
- _Str := GetXmlNodeValue(X, '@Code');
- if _Str = '28' then begin
- // неправильный пароль
- ;
- end;
- end;
- end;
- finally
- _ServerConnection.Free;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment