csg-session-timer
v2.3.0
Published
Session timer component for web applications that rely on server side session management and need to prompt users to extend sessions after periods of inactivity
Downloads
6
Readme
csg-session-timer
Table of Contents
To install, you can use npm or yarn:
$ npm install csg-session-timer
$ yarn add csg-session-timer
Examples
Here is a simple example of csg-session-timer being used in an app
import React from 'react';
import ReactDOM from 'react-dom';
import CsgSessionTimer from 'csg-session-timer'
import CSGApiClient from './common/api/csg/CSGApiClient'
// initializing the props to pass to the component
const appElement = "#main" // Make sure this element is used in all authenticated views/layouts of your app
const sessionResource = "http://myapi.mywebapp.com/v1/auth/users/sessions.json" // *required* URL to the REST API endpoint for your session management
const refreshSessionResource = "http://myapi.mywebapp.com/oauth/v1/token"; // *required* URL to the REST API endpoint for your session extension (uses HTTP HEAD request)
const sessionLimit = 1000*60*25 //*required* the time limit for your web session represented in miliseconds
const timerDuration = 1000*60*5 //*required* the amount of time, represented in miliseconds, to give users to extend their session to be shown in a popup dialog
const logoutURI = "/auth/signout" // *optional* defaults to "/auth/signout";
const clientResource = CSGAPIClient //We use CSGAPI client to make authenticated calls to the API
ReactDOM.render(
<React.StrictMode>
<CsgSessionTimer
sessionResource={session}
logOutRedirectURI={logoutURI}
sessionLimit={sessionLimit}
timerDuration={timerDuration}
refreshSessionResource={refreshSessionResource}
appElement={"root"}
clientResource={CSGApiClient}
/>
</React.StrictMode>,,
appElement);