diff --git a/app.py b/app.py index b0fb831..38bc43a 100644 --- a/app.py +++ b/app.py @@ -50,16 +50,17 @@ def serve_layout(): # Define callbacks for the app # ============================================================== -@app.callback(Output('session-id', 'data'), +@app.callback([Output('session-id', 'data'), + Output('url', 'pathname')], [Input({'type': 'clear-storage-button', 'index': ALL}, 'n_clicks')]) def start_new_session(n_clicks): trigger = dash.callback_context.triggered[0] if not callback_utils.ensure_triggered(trigger): - return no_update + return no_update, no_update else: cache = keydb.KeyDB(connection_pool=keydb_pool) new_session_id = session_utils.initiate_session(cache, app.logger) - return new_session_id + return new_session_id, UrlIndex.HOME.value @app.callback([Output('contact-alert-div', 'children'), diff --git a/components/links.py b/components/links.py index b7e9cd3..32ca255 100644 --- a/components/links.py +++ b/components/links.py @@ -4,10 +4,8 @@ def StartNewSessionLink(): - return dbc.NavLink( - dbc.Button( - "Start new session", block=True, color='danger', id={'type': 'clear-storage-button', 'index': '1'} - ), href=UrlIndex.ROOT.value, style={"text-decoration": "none"}) + return dbc.Button("Start new session", block=True, color='danger', + id={'type': 'clear-storage-button', 'index': '1'}) def GitHubLink(): diff --git a/components/modals.py b/components/modals.py index bc423d2..9ff3e08 100644 --- a/components/modals.py +++ b/components/modals.py @@ -84,7 +84,7 @@ def SessionTimedOutModal(): return dbc.Modal([ ModalHeader("Session timed-out"), dbc.ModalBody([ - html.P("""More than 15 minutes have passed since you last interacted with the website and your session has + html.P("""More than 60 minutes have passed since you last interacted with the website and your session has timed-out.""", style={'text-align': "justify"}), components.StartNewSessionLink() ]), diff --git a/utils/session_utils.py b/utils/session_utils.py index a7b102c..e2037de 100644 --- a/utils/session_utils.py +++ b/utils/session_utils.py @@ -86,7 +86,7 @@ def decompress_session(session): return session -def is_expired_session(session_id, cache, logger, expire_time=900): +def is_expired_session(session_id, cache, logger, expire_time=3600): if not cache.exists(session_id): logger.info('Session {} has expired'.format(session_id)) return True @@ -95,7 +95,7 @@ def is_expired_session(session_id, cache, logger, expire_time=900): return False -def initiate_session(cache, logger, expire_time=900): +def initiate_session(cache, logger, expire_time=3600): session_id = str(uuid.uuid4()) logger.info('New session initiated {}'.format(session_id)) cache.hset(session_id, cache_utils.CacheKeys.ID.value, compress_data(session_id))