MarcoPis Posted September 28, 2021 Share Posted September 28, 2021 Hi, Sorry for this new topic, but I was unable to answer on the old post. I just made a HTTP call in UniGui Desktop and it works perfectly. I made the same in UniGui Mobile using mobile components and it's not working. I Have Delphi 10.3 and UniGui (Complete Professional) 1.90.0.1545 HTTP - Request procedure TUFmLoginm.btLoginRequestClick(Sender: TObject); Var aUrlSubmit, aUrlCancel, aUrl, sProtocol :string; Begin frmPinm.UnimURLFrame1.URL := ''; if UniServerModule.PINEndPoint.Contains('https') then sProtocol := 'https' else sProtocol := 'http'; aUrlSubmit := UniSession.CallbackUrlEx('loggedwithcredentials', self, ['RES', 'OK']); if sProtocol.Contains('https') and not aUrlSubmit.Contains('https') then aUrlSubmit := aUrlSubmit.Replace('http', sProtocol, []); aUrlSubmit := aUrlSubmit.Replace(#$D#$A, '', [rfReplaceAll]); aUrlSubmit := TNetEncoding.URL.Encode(TStringRoutines.GetBase64CryptedString(aUrlSubmit)); aUrlCancel := UniSession.CallbackUrlEx('logincancelled', self, ['RES', 'Cancel']); if sProtocol.Contains('https') and not aUrlCancel.Contains('https') then aUrlCancel := aUrlCancel.Replace('http', sProtocol, []); aUrlCancel := aUrlCancel.Replace(#$D#$A, '', [rfReplaceAll]); aUrlCancel := TNetEncoding.URL.Encode(TStringRoutines.GetBase64CryptedString(aUrlCancel)); if TUniGUIApplication(UniApplication).Parameters.values['gestore'].IsEmpty then aUrl := UniServerModule.PINEndPoint+'/?action=authn&gestore='+UniMainModule.gestore+'&url_submit='+aUrlSubmit+'&url_cancel='+aUrlCancel+'&_S_ID='+UniSession.SessionId+'&appid='+UniMainModule.appID else aUrl := UniServerModule.PINEndPoint+'/?action=authn&gestore='+TUniGUIApplication(UniApplication).Parameters.values['gestore']+'&url_submit='+aUrlSubmit+'&url_cancel='+aUrlCancel+'&_S_ID='+UniSession.SessionId+'&appid='+UniMainModule.appID; frmPinm.UnimURLFrame1.URL := aURL; frmPinm.Show End; End Point procedure TFrmAuthnm.FormPost; var data_event : string; begin { ... elaboration ... } with UniMainModule.GetDM do begin if not UniMainModule.Url_submit.IsEmpty then begin if FResponsePost then begin s := 'var f = document.createElement("form"); '+ 'f.action="'+UniMainModule.Url_submit+'"; '+ // the second app url 'f.method="POST"; '; s := s+ 'var i=document.createElement("input"); '+ // url_submit 'i.type="hidden"; '+ 'i.name="data_event"; '+ 'i.value="'+TNetEncoding.Url.Encode(data_event)+'"; '+ 'f.appendChild(i); '; s := s+ 'document.body.appendChild(f); '+ 'f.submit(); '; UniSession.AddJS(s) end else UniSession.UrlRedirect(UniMainModule.Url_submit+'&data_event='+TNetEncoding.Url.Encode(data_event)); end; end; Ajax Event that intercept CallBack procedure TUFmLoginm.UnimLoginFormAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var jsonResponse, aURL : string; credentials : TLoginCredentials; begin if (EventName = 'loggedwithcredentials') and (Params.Values['RES']='OK') then begin if not Params.Values['data_event'].IsEmpty then begin // elab .... frmPinm.Hide; ModalResult := mrOK finally credentials.Free end end end end; All works fine except AjaxEvent that doesn't intercept the EventName "loggedwithcredentials". Link to comment Share on other sites More sharing options...
Sherzod Posted September 28, 2021 Share Posted September 28, 2021 3 minutes ago, MarcoPis said: UniGui (Complete Professional) 1.90.0.1545 Please adjust your forum email address first: Link to comment Share on other sites More sharing options...
Recommended Posts