Skip to content

Commit

Permalink
Merge pull request #2726 from sgilbride/web_login_timeout_fix
Browse files Browse the repository at this point in the history
Web Admin Page Timeout Fix
  • Loading branch information
shwethanidd authored Jul 20, 2021
2 parents ab6d7e8 + 7b42ea5 commit c84a316
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions volttron/platform/web/admin_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from urllib.parse import parse_qs

from volttron.platform.agent.known_identities import PLATFORM_WEB, AUTH
from volttron.platform.jsonrpc import RemoteError

try:
from jinja2 import Environment, FileSystemLoader, select_autoescape, TemplateNotFound
Expand Down Expand Up @@ -160,6 +161,14 @@ def verify_and_dispatch(self, env, data):
except NotAuthorized:
_log.error("Unauthorized user attempted to connect to {}".format(env.get('PATH_INFO')))
return Response('<h1>Unauthorized User</h1>', status="401 Unauthorized")
except RemoteError as e:
if "ExpiredSignatureError" in e.exc_info["exc_type"]:
_log.warning("Access token has expired! Please re-login to renew.")
template = template_env(env).get_template('login.html')
_log.debug("Login.html: {}".format(env.get('PATH_INFO')))
return Response(template.render(), content_type='text/html')
else:
_log.error(e)

# Make sure we have only admins for viewing this.
if 'admin' not in claims.get('groups'):
Expand Down

0 comments on commit c84a316

Please sign in to comment.