Skip to content

xp-forge/htmx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTMX for XP web frontends

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.4+ Supports PHP 8.0+ Latest Stable Version

HTMX Integration

Authentication

Wrap any authentication flow in a HtmxFlow to ensure authentication does not redirect but instead yields an error code and triggers an event:

+ use web\frontend\HtmxFlow;

- $auth= new SessionBased($flow, $sessions);
+ $auth= new SessionBased(new HtmxFlow($flow), $sessions);

Handle this inside JavaScript with something along the lines of the following:

window.addEventListener('authenticationexpired', e => {
  if (confirm('Authentication expired. Do you want to re-authenticate?')) {
    window.location.reload();
  }
});