我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用django.contrib.auth.views.logout_then_login()。
def logout(request): """ Log users out (destroy all sessions) and re-direct them to the main page. """ # Save profile and user object user = request.user profile = request.user.userprofile # Create guacamole object attached to request.user.username and with current guacamole password g = GuacamoleAuth(request) # Do a guacamole logout gcookie = g.logout() # We can then remove the cached configuration g.del_auth() # Get the response object response = logout_then_login(request) # Remove the guacamole cookie from response object response.delete_cookie(**gcookie['cookie']) # Setup i18n settings of the logged in user into session of an anonymous user profile.activate_locale(request) # Get auth logger and log the logout :) auth_logger.info('User %s successfully logged out from %s (%s)', user, get_client_ip(request), request.META.get('HTTP_USER_AGENT', '')) # Bye bye return response