def admin_session_timedout(): ''' Check if the current user has been authenticated for more than what is allowed (defaults to 15 minutes). If it is the case, the user is logged out and the method returns True, otherwise it returns False. ''' timedout = False if not authenticated(): return True if (datetime.datetime.utcnow() - flask.g.fas_user.login_time) > \ APP.config.get('ADMIN_SESSION_LIFETIME', datetime.timedelta(minutes=15)): timedout = True FAS.logout() return timedout
def auth_logout(): # pragma: no cover """ Method to log out from the application. """ return_point = flask.url_for('index') if 'next' in flask.request.args: if is_safe_url(flask.request.args['next']): return_point = flask.request.args['next'] if not authenticated(): return flask.redirect(return_point) if APP.config.get('PAGURE_AUTH', None) == 'fas': if hasattr(flask.g, 'fas_user') and flask.g.fas_user is not None: FAS.logout() flask.flash("You are no longer logged-in") elif APP.config.get('PAGURE_AUTH', None) == 'local': login.logout() return flask.redirect(return_point)