Skip to content

Commit 4dd155e

Browse files
committed
feat: add ability to logout immediately
* add "Logout Now" in idle timeout modal * reset modal display time when user resumes session
1 parent 1949c12 commit 4dd155e

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

config/constants/development.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module.exports = {
4141
FILE_PICKER_REGION: 'us-east-1',
4242
FILE_PICKER_CNAME: 'fs.topcoder.com',
4343
// if idle for this many minutes, show user a prompt saying they'll be logged out
44-
IDLE_TIMEOUT_MINUTES: 10,
44+
IDLE_TIMEOUT_MINUTES: 1,
4545
// duration to show the prompt saying user will be logged out, before actually logging out the user
46-
IDLE_TIMEOUT_GRACE_MINUTES: 5
46+
IDLE_TIMEOUT_GRACE_MINUTES: 1
4747
}

src/routes.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { connect } from 'react-redux'
1818
import { checkAllowedRoles } from './util/tc'
1919
import { setCookie, removeCookie, isBetaMode } from './util/cookie'
2020
import IdleTimer from 'react-idle-timer'
21-
import AlertModal from './components/Modal/AlertModal'
2221
import modalStyles from './styles/modal.module.scss'
22+
import ConfirmationModal from './components/Modal/ConfirmationModal'
2323

2424
const { ACCOUNTS_APP_LOGIN_URL, IDLE_TIMEOUT_MINUTES, IDLE_TIMEOUT_GRACE_MINUTES, COMMUNITY_APP_URL } = process.env
2525

@@ -127,21 +127,25 @@ class Routes extends React.Component {
127127
}
128128

129129
const isAllowed = checkAllowedRoles(_.get(decodeToken(this.props.token), 'roles'))
130-
const modal = (<AlertModal
130+
const modal = (<ConfirmationModal
131131
theme={theme}
132132
title='Session Timeout'
133133
message={`You've been idle for quite sometime. You'll be automatically logged out in ${this.state.logsoutIn >= 60 ? Math.ceil(this.state.logsoutIn / 60) + ' minute(s).' : this.state.logsoutIn + ' second(s)'}`}
134-
closeText='Resume Session'
135-
onClose={() => {
134+
confirmText='Logout Now'
135+
cancelText='Resume Session'
136+
onCancel={() => {
136137
clearInterval(this.state.logoutIntervalRef)
137138
if (this.idleTimer.isIdle()) {
138139
this.idleTimer.resume()
139140
this.idleTimer.reset()
140141
this.setState(state => ({
141-
...state, showIdleModal: false, logsoutIn: 120
142+
...state, showIdleModal: false, logsoutIn: IDLE_TIMEOUT_GRACE_MINUTES * 60
142143
}))
143144
}
144145
}}
146+
onConfirm={() => {
147+
window.location = `${COMMUNITY_APP_URL}/logout`
148+
}}
145149
/>)
146150

147151
return (

0 commit comments

Comments
 (0)