Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 3 of 3 total |
Authentication of User / Password |
Tue, Jan 10 2023 1:58 PM | Permanent Link |
Richard Harding Wise Nutrition Coaching | Greetings
Below is the code I use to authenticate users. The windows parameter string is parsed to determine the: HostName, Port and DefaultPort. How do we get a simple, elegant, developer-friendly solution that is shown in the application to determine that Authentication has failed? procedure TfmCountryList.fmCountryListCreate(Sender: TObject); var i: integer; ParamString: string; S1, S2: array of string; begin logoutput('TfmCountryList.fmCountryListCreate', 'log'); Database.Name := 'Countries'; Database.AutoTransactions := false; Session.Name := 'Session'; Session.OnComplete := sessionComplete; ParamString := copy(window.location.search, 2); logoutput('ParamString: ' + paramString, 'log'); // Obtain Session.BaseURL from host name and port number in ParamString // ?hostname=<host name>&port=<port>&defaultport=<defaultport> logoutput(' ---------------', 'log'); // Parse "ParamString' to determine HostName, PortNumber, DefaultPault // Code not shown session.BaseURL := 'http://' + Host + ':' + IntToStr(PortNumber); logoutput('Session.BaseURL: ' + Session.BaseURL, 'log'); session.UserName := 'Anonymous'; // session.password is assigned to the invalid 'X' session.password := 'X'; Application.Surface.Background.Fill.Color := clAntiqueWhite; try logoutput('try session.Authenticate', 'log'); session.Authenticate; except logoutput('Error in authenticating! - Username / password incorrect', 'log'); end; end else // if length(ParamString) > 0 begin Logoutput('No html parameters', 'log'); end; end; procedure TfmCountryList.SessionComplete(Session: TServerSession); begin Logoutput('SessionComplete', 'log'); if Session.Authenticated then begin Database.OnCommitError := CommitError; Database.AfterCommit := AfterCommit; Database.BeforeCommit := BeforeCommit; Database.OnRollbackError := RollbackError; Database.AfterRollback := AfterRollback; AllCountriesSummary.Open; Database.LoadRows(AllCountriesSummary); end else begin logoutput('Session not authenticated', 'log'); end; end; A ShowError procedure shows the details of the TExternalObject Log output: ERROR: Error executing request "http://localhost:8300/authentication" (Authentication error for user Anonymous (Invalid user or password) ) at line 26439: undefined Richard |
Thu, Feb 2 2023 3:12 AM | Permanent Link |
Ralf Mimoun | I use
procedure TfrmMain.SessionComplete(Session: TServerSession); begin if Session.RequestStatusCode <> HTTP_OK then begin [Show Error] end; end; in my projects. |
Mon, Feb 6 2023 6:47 AM | Permanent Link |
Richard Harding Wise Nutrition Coaching | Thank you Ralf.
Richard |
This web page was last updated on Monday, April 22, 2024 at 04:13 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |