def logout_user(): user = _get_user() if (_get_endpoint() + '_id') in session: session.pop(_get_endpoint() + '_id') if (_get_endpoint() + '_user_id') in session: session.pop(_get_endpoint() + '_user_id') if (_get_endpoint() + '_fresh') in session: session.pop(_get_endpoint() + '_fresh') cookie_name =_get_endpoint() + '_' +current_app.config.get('REMEMBER_COOKIE_NAME', COOKIE_NAME) if cookie_name in request.cookies: session[_get_endpoint() + '_remember'] = 'clear' if (_get_endpoint() + '_remember_seconds') in session: session.pop(_get_endpoint() + '_remember_seconds') user_logged_out.send(current_app._get_current_object(), user=user) current_app.login_manager.reload_user() return True
def logout_user(): ''' Logs a user out. (You do not need to pass the actual user.) This will also clean up the remember me cookie if it exists. ''' user = _get_user() session.pop('user_id', None) session.pop('user_data', None) session.pop('_fresh', None) cookie_name = current_app.config.get('REMEMBER_COOKIE_NAME', COOKIE_NAME) if cookie_name in request.cookies: session['remember'] = 'clear' if 'remember_seconds' in session: session.pop('remember_seconds') user_logged_out.send(current_app._get_current_object(), user=user) current_app.login_manager.reload_user() return True