I've written a custom module for Drupal 8 to monitor user device location frequently. If a user goes out of an allowed zone boundary, I need to force logging the user out of the website. I created following files in the module folder (gps_test):
- File gps_test.info.yml
- File gps.js: JavaScript program to monitor the user device's GPS location.
- File gps_test.libraries.yml: Contains the gps.js library.
- File gps_test.module: Implements a hook to attach the JavaScript library on every page load.
function gps_test_page_attachments(array &$page) {
$page['#attached']['library'][] = 'gps_test/gps';
}
How can I force the user being logged out (or prevent the user from using the website) from the gps.js library?