a week ago - last edited a week ago
Hallo everyone,
I need to create a plugin session for timeout in the Launchpad, when the user is inactive for two minutes, he will reseive a notification ( see the photo please) with countdown timer for example 5 minutes, telling him that he will be forced to logout if in 5 minutes if inactivity continues.
The Plugin should appear next to the Search plugin.
Have someone an idea, step by step please?
Thank you.
You can make use of mousemove and keypress events to constantly update user's last interaction time. Upon long inactivity, you can display your timer and finally logout the user by forwarding them to logout URL. See following code for a rough idea of how to do it:
1. Constantly update user's last interaction info using "mousemove" and "keypress" events:
var glbl_usr_last_intrction = Date.now();
const update_timestamp = () => {
glbl_usr_last_intrction = Date.now();
hide_timer(); //in case timer was visible
}
window.addEventListener('mousemove', update_timestamp);
window.addEventListener('keypress', update_timestamp);
2. Check user's last interaction time every 10 seconds and display the timer or logout if inactive for too long:
const inactive_threshold_timer = 120000; // 2 minutes
const inactive_threshold_logout = 420000; // 7 minutes
const check_last_intrction = () => {
if (Date.now() - glbl_usr_last_intrction > inactive_threshold_logout) {
window.location.href = "/sap/public/bc/icf/logoff";
return;
}
if (Date.now() - glbl_usr_last_intrction > inactive_threshold_timer) {
display_timer();
}
setTimeout(check_last_intrction, 10000);
}
check_last_intrction();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
109 | |
15 | |
10 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.