csg-session-timer

2.3.0 • Public • Published

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);

Readme

Keywords

none

Package Sidebar

Install

npm i csg-session-timer

Weekly Downloads

13

Version

2.3.0

License

MIT

Unpacked Size

54.9 kB

Total Files

3

Last publish

Collaborators

  • csg_actuarial