Expiration de la session
But
Créer un délai d'inactivité qui avertit les utilisateurs lorsque leur session est sur le point d'expirer.
Ce plugiciel aidera les propriétaires d'actifs Web à configurer leurs actifs avec une fonction « Expiration de la session ». Celle-ci sera activée en deux circonstances : après une période de temps spécifique ou lors d'inactivité.
Par exemple, si l'utilisateur demeure trop longtemps sur la même page, la fonction sera activée. De même, si l’utilisateur demeure inactif, la fonction sera activée. Le fureteur affichera alors une boîte de dialogue proposant deux options à l'utilisateur ; s’il souhaite rester connecté il devra sélectionner « Continuer la session » et ce, dans un laps de temps précis et s’il souhaite mettre fin à sa session, il n’aura qu’à choisir « Mettre fin à la session ». Advenant que l'utilisateur tarde trop à faire son choix, ce sera le paramètre de déconnexion qui s’affichera.
Needs translation
Use when
- A session timeout warning is required. This will alert the user before their session expires and give them a chance to extend the session.
- User activity on a web page should extend their session.
Exemple pratique
Needs translation
How to implement
-
Add a
class="wb-sessto"
element to the web page (only required once). You must set thelogouturl
, which controls where the user is redirected if their session expires:<span class="wb-sessto" data-wb-sessto='{"logouturl": "https://app.gc.ca/logout"}'></span>
- Configure the plugin using the
data-wb-sessto
attribute of the element:<span class="wb-sessto" data-wb-sessto='{ "inactivity": 1200000, "reactionTime": 30000, "sessionalive": 1200000, "logouturl": "./", "signInUrl": null, "refreshCallbackUrl": "./", "refreshOnClick": true, "refreshLimit": 200000}'></span>
Configuration options
All configuration options of the plugin are controlled by the data-wb-sessto
attribute or window[ "wb-sessto" ]
. Any configuration parameter that accepts a time value, can optionally have the time unit specified (e.g. "100 ms").
Supported time units are:
ms
: millisecond (0.001 seconds)cs
: centisecond (0.01 seconds)ds
: decisecond (0.1 seconds)s
: seconds (1 second)das
: dekasecond (10 seconds)hs
: hectosecond (100 seconds)ks
: kilosecond (1,000 seconds)
Option | Description | How to configure | Values |
---|---|---|---|
inactivity |
Sets the inactivity timeout. Once this expires, the plugin's modal dialog will appear and prompt the user to continue or end their session. | Provide a numeric value, optionally with a time unit appended. |
|
reactionTime |
Sets the period of time the user has to perform an action once the modal dialog is displayed | Provide a numeric value, optionally with a time unit appended. |
|
sessionalive |
Sets the period of time before an ajax request is made to the server to determine if the session is still alive. A refreshCallbackUrl must be specified for this to work. |
Provide a numeric value, optionally with a time unit appended. |
|
logouturl |
URL that users are sent to when their session has expired. | Provide a URL. |
|
signInUrl |
URL to the Sign-In page. | Provide a URL. |
|
refreshCallback |
The function used to check the response received from refreshCallbackUrl . This parameter cannot be specified on the data-wb-sessto attribute. |
Provide a function. |
|
refreshCallbackUrl |
URL used to perform an ajax request to determine the validity of the session. See the method and refreshCallback parameters for more details. |
Provide a URL. |
|
refreshOnClick |
Determines if clicking on the document should reset the inactivity timeout and perform an ajax request (if a refreshCallbackUrl has been specified). |
Provide a boolean true/false value. |
|
refreshLimit |
Sets the amount of time that must pass before an ajax request can be made. | Provide a numeric value, optionally with a time unit appended. |
|
method |
Sets the request method used for ajax requests. While all methods are accepted, the response must contain a message body therefore methods that preclude this are not recommended. Recommended: GET, POST. | Provide a string value. |
|
additionalData |
Additional data to send with the request. | Provide a string value, array, object or null. |
|
Events
Document the public events that can be used by implementers or developers.
Event | Trigger | What it does |
---|---|---|
wb-init.wb-sessto |
Triggered manually (e.g., $( ".wb-sessto" ).trigger( "wb-init.wb-sessto" ); ). |
Initializes the plugin and starts the session and inactivity timeouts. Note: the session timeout plugin will be initialized automatically unless the .wb-sessto element is added after the page has already loaded. |
wb-ready.wb-sessto (v4.0.5+) |
Triggered automatically after the Session timeout plugin initializes. | Used to identify when and where the Session timeout plugin initializes (target of the event).
|
inactivity.wb-sessto |
Triggered manually and by the plugin (e.g., $( ".wb-sessto" ).trigger( "inactivity.wb-sessto" ); ). |
Causes the modal dialog to appear and prompt the user to continue or end their session. This event is triggered automatically when the inactivity timeout expires. |
keepalive.wb-sessto |
Triggered manually and by the plugin (e.g., $( ".wb-sessto" ).trigger( "keepalive.wb-sessto" ); ). |
Causes an ajax request to be made (if a refreshCallbackUrl has been specified). This will alert the user that their session has expired if the refreshCallbackUrl response is not "true". |
reset.wb-sessto |
Triggered manually and by the plugin (e.g., $( ".wb-sessto" ).trigger( "reset.wb-sessto" ); ). |
Restarts the inactivity and keepalive timeouts. |
wb-ready.wb (v4.0.5+) |
Triggered automatically when WET has finished loading and executing. | Used to identify when all WET plugins and polyfills have finished loading and executing.
|
Note: when manually triggering the inactivity
, keepalive
and reset
events, you must pass the data-wb-sessto
attribute as a second argument:
// Get a reference to the session timeout element and its data-wb-sessto
attribute
var $element = $( ".wb-sessto" ),
settings = $element.data( "wb-sessto" );
// Trigger the event on the element
$element.trigger( "reset.wb-sessto", settings );
Source code
- Date de modification :