def set_demo_mode(): if app.config['DEMO_MODE_AVAILABLE']: in_demo_mode = request.get_json().get('demoMode', None) if in_demo_mode is None: raise errors.BadRequestError('Parameter \'demoMode\' not found') user = AuthorizedUser.find_by_id(current_user.get_id()) user.in_demo_mode = bool(in_demo_mode) current_user.flush_cached() app.login_manager.reload_user() return tolerant_jsonify(current_user.to_api_json()) else: raise errors.ResourceNotFoundError('Unknown path')
def _logout_user(): if current_user: current_user.flush_cached() logout_user()