<s> from django . core . urlresolvers import reverse , reverse_lazy <EOL> from django . http import ( HttpResponseRedirect , Http404 , <EOL> HttpResponsePermanentRedirect ) <EOL> from django . views . generic . base import TemplateResponseMixin , View , TemplateView <EOL> from django . views . generic . edit import FormView <EOL> from django . contrib import messages <EOL> from django . contrib . auth . decorators import login_required <EOL> from django . contrib . auth import logout as auth_logout <EOL> from django . shortcuts import redirect <EOL> from django . views . decorators . debug import sensitive_post_parameters <EOL> from django . utils . decorators import method_decorator <EOL> from . . exceptions import ImmediateHttpResponse <EOL> from . . utils import get_form_class , get_request_param , get_current_site <EOL> from . utils import ( get_next_redirect_url , complete_signup , <EOL> get_login_redirect_url , perform_login , <EOL> passthrough_next_redirect_url , url_str_to_user_pk , <EOL> logout_on_password_change ) <EOL> from . forms import ( <EOL> AddEmailForm , ChangePasswordForm , <EOL> LoginForm , ResetPasswordKeyForm , <EOL> ResetPasswordForm , SetPasswordForm , SignupForm , UserTokenForm ) <EOL> from . utils import sync_user_email_addresses <EOL> from . models import EmailAddress , EmailConfirmation , EmailConfirmationHMAC <EOL> from . import signals <EOL> from . import app_settings <EOL> from . adapter import get_adapter <EOL> sensitive_post_parameters_m = method_decorator ( <EOL> sensitive_post_parameters ( '<STR_LIT:password>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def _ajax_response ( request , response , form = None ) : <EOL> if request . is_ajax ( ) : <EOL> if ( isinstance ( response , HttpResponseRedirect ) or isinstance ( <EOL> response , HttpResponsePermanentRedirect ) ) : <EOL> redirect_to = response [ '<STR_LIT>' ] <EOL> else : <EOL> redirect_to = None <EOL> response = get_adapter ( request ) . ajax_response ( <EOL> request , <EOL> response , <EOL> form = form , <EOL> redirect_to = redirect_to ) <EOL> return response <EOL> class RedirectAuthenticatedUserMixin ( object ) : <EOL> def dispatch ( self , request , * args , ** kwargs ) : <EOL> self . request = request <EOL> if request . user . is_authenticated ( ) and app_settings . AUTHENTICATED_LOGIN_REDIRECTS : <EOL> redirect_to = self . get_authenticated_redirect_url ( ) <EOL> response = HttpResponseRedirect ( redirect_to ) <EOL> return _ajax_response ( request , response ) <EOL> else : <EOL> response = super ( RedirectAuthenticatedUserMixin , <EOL> self ) . dispatch ( request , <EOL> * args , <EOL> ** kwargs ) <EOL> return response <EOL> def get_authenticated_redirect_url ( self ) : <EOL> redirect_field_name = self . redirect_field_name <EOL> return get_login_redirect_url ( self . request , <EOL> url = self . get_success_url ( ) , <EOL> redirect_field_name = redirect_field_name ) <EOL> class AjaxCapableProcessFormViewMixin ( object ) : <EOL> def post ( self , request , * args , ** kwargs ) : <EOL> form_class = self . get_form_class ( ) <EOL> form = self . get_form ( form_class ) <EOL> if form . is_valid ( ) : <EOL> response = self . form_valid ( form ) <EOL> else : <EOL> response = self . form_invalid ( form ) <EOL> return _ajax_response ( self . request , response , form = form ) <EOL> class LoginView ( RedirectAuthenticatedUserMixin , <EOL> AjaxCapableProcessFormViewMixin , <EOL> FormView ) : <EOL> form_class = LoginForm <EOL> template_name = "<STR_LIT>" + app_settings . TEMPLATE_EXTENSION <EOL> success_url = None <EOL> redirect_field_name = "<STR_LIT>" <EOL> @ sensitive_post_parameters_m <EOL> def dispatch ( self , request , * args , ** kwargs ) : <EOL> return super ( LoginView , self ) . dispatch ( request , * args , ** kwargs ) <EOL> def get_form_kwargs ( self ) : <EOL> kwargs = super ( LoginView , self ) . get_form_kwargs ( ) <EOL> kwargs [ '<STR_LIT>' ] = self . request <EOL> return kwargs <EOL> def get_form_class ( self ) : <EOL> return get_form_class ( app_settings . FORMS , '<STR_LIT>' , self . form_class ) <EOL> def form_valid ( self , form ) : <EOL> success_url = self . get_success_url ( ) <EOL> try : <EOL> return form . login ( self . request , redirect_url = success_url ) <EOL> except ImmediateHttpResponse as e : <EOL> return e . response <EOL> def get_success_url ( self ) : <EOL> ret = ( get_next_redirect_url ( <EOL> self . request , <EOL> self . redirect_field_name ) or self . success_url ) <EOL> return ret <EOL> def get_context_data ( self , ** kwargs ) : <EOL> ret = super ( LoginView , self ) . get_context_data ( ** kwargs ) <EOL> signup_url = passthrough_next_redirect_url ( self . request , <EOL> reverse ( "<STR_LIT>" ) , <EOL> self . redirect_field_name ) <EOL> redirect_field_value = get_request_param ( self . request , <EOL> self . redirect_field_name ) <EOL> site = get_current_site ( self . request ) <EOL> ret . update ( { "<STR_LIT>" : signup_url , <EOL> "<STR_LIT>" : site , <EOL> "<STR_LIT>" : self . redirect_field_name , <EOL> "<STR_LIT>" : redirect_field_value } ) <EOL> return ret <EOL> login = LoginView . as_view ( ) <EOL> class CloseableSignupMixin ( object ) : <EOL> template_name_signup_closed = ( <EOL> "<STR_LIT>" + app_settings . TEMPLATE_EXTENSION ) <EOL> def dispatch ( self , request , * args , ** kwargs ) : <EOL> self . request = request <EOL> try : <EOL> if not self . is_open ( ) : <EOL> return self . closed ( ) <EOL> except ImmediateHttpResponse as e : <EOL> return e . response <EOL> return super ( CloseableSignupMixin , self ) . dispatch ( request , <EOL> * args , <EOL> ** kwargs ) <EOL> def is_open ( self ) : <EOL> return get_adapter ( self . request ) . is_open_for_signup ( self . request ) <EOL> def closed ( self ) : <EOL> response_kwargs = { <EOL> "<STR_LIT>" : self . request , <EOL> "<STR_LIT>" : self . template_name_signup_closed , <EOL> } <EOL> return self . response_class ( ** response_kwargs ) <EOL> class SignupView ( RedirectAuthenticatedUserMixin , CloseableSignupMixin , <EOL> AjaxCapableProcessFormViewMixin , FormView ) : <EOL> template_name = "<STR_LIT>" + app_settings . TEMPLATE_EXTENSION <EOL> form_class = SignupForm <EOL> redirect_field_name = "<STR_LIT>" <EOL> success_url = None <EOL> @ sensitive_post_parameters_m <EOL> def dispatch ( self , request , * args , ** kwargs ) : <EOL> return super ( SignupView , self ) . dispatch ( request , * args , ** kwargs ) <EOL> def get_form_class ( self ) : <EOL> return get_form_class ( app_settings . FORMS , '<STR_LIT>' , self . form_class ) <EOL> def get_success_url ( self ) : <EOL> ret = ( <EOL> get_next_redirect_url ( <EOL> self . request , <EOL> self . redirect_field_name ) or self . success_url ) <EOL> return ret <EOL> def form_valid ( self , form ) : <EOL> self . user = form . save ( self . request ) <EOL> return complete_signup ( self . request , self . user , <EOL> app_settings . EMAIL_VERIFICATION , <EOL> self . get_success_url ( ) ) <EOL> def get_context_data ( self , ** kwargs ) : <EOL> ret = super ( SignupView , self ) . get_context_data ( ** kwargs ) <EOL> form = ret [ '<STR_LIT>' ] <EOL> form . fields [ "<STR_LIT:email>" ] . initial = self . request . session . get ( '<STR_LIT>' ) <EOL> login_url = passthrough_next_redirect_url ( self . request , <EOL> reverse ( "<STR_LIT>" ) , <EOL> self . redirect_field_name ) <EOL> redirect_field_name = self . redirect_field_name <EOL> redirect_field_value = get_request_param ( self . request , <EOL> redirect_field_name ) <EOL> ret . update ( { "<STR_LIT>" : login_url , <EOL> "<STR_LIT>" : redirect_field_name , <EOL> "<STR_LIT>" : redirect_field_value } ) <EOL> return ret <EOL> signup = SignupView . as_view ( ) <EOL> class ConfirmEmailView ( TemplateResponseMixin , View ) : <EOL> template_name = "<STR_LIT>" + app_settings . TEMPLATE_EXTENSION <EOL> def get ( self , * args , ** kwargs ) : <EOL> try : <EOL> self . object = self . get_object ( ) <EOL> if app_settings . CONFIRM_EMAIL_ON_GET : <EOL> return self . post ( * args , ** kwargs ) <EOL> except Http404 : <EOL> self . object = None <EOL> ctx = self . get_context_data ( ) <EOL> return self . render_to_response ( ctx ) <EOL> def post ( self , * args , ** kwargs ) : <EOL> self . object = confirmation = self . get_object ( ) <EOL> confirmation . confirm ( self . request ) <EOL> get_adapter ( self . request ) . add_message ( <EOL> self . request , <EOL> messages . SUCCESS , <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT:email>' : confirmation . email_address . email } ) <EOL> if app_settings . LOGIN_ON_EMAIL_CONFIRMATION : <EOL> resp = self . login_on_confirm ( confirmation ) <EOL> if resp is not None : <EOL> return resp <EOL> redirect_url = self . get_redirect_url ( ) <EOL> if not redirect_url : <EOL> ctx = self . get_context_data ( ) <EOL> return self . render_to_response ( ctx ) <EOL> return redirect ( redirect_url ) <EOL> def login_on_confirm ( self , confirmation ) : <EOL> """<STR_LIT>""" <EOL> user_pk = None <EOL> user_pk_str = get_adapter ( self . request ) . unstash_user ( self . request ) <EOL> if user_pk_str : <EOL> user_pk = url_str_to_user_pk ( user_pk_str ) <EOL> user = confirmation . email_address . user <EOL> if user_pk == user . pk and self . request . user . is_anonymous ( ) : <EOL> return perform_login ( self . request , <EOL> user , <EOL> app_settings . EmailVerificationMethod . NONE , <EOL> redirect_url = self . get_redirect_url ) <EOL> return None <EOL> def get_object ( self , queryset = None ) : <EOL> key = self . kwargs [ '<STR_LIT:key>' ] <EOL> emailconfirmation = EmailConfirmationHMAC . from_key ( key ) <EOL> if not emailconfirmation : <EOL> if queryset is None : <EOL> queryset = self . get_queryset ( ) <EOL> try : <EOL> emailconfirmation = queryset . get ( key = key . lower ( ) ) <EOL> except EmailConfirmation . DoesNotExist : <EOL> raise Http404 ( ) <EOL> return emailconfirmation <EOL> def get_queryset ( self ) : <EOL> qs = EmailConfirmation . objects . all_valid ( ) <EOL> qs = qs . select_related ( "<STR_LIT>" ) <EOL> return qs <EOL> def get_context_data ( self , ** kwargs ) : <EOL> ctx = kwargs <EOL> ctx [ "<STR_LIT>" ] = self . object <EOL> return ctx <EOL> def get_redirect_url ( self ) : <EOL> return get_adapter ( self . request ) . get_email_confirmation_redirect_url ( <EOL> self . request ) <EOL> confirm_email = ConfirmEmailView . as_view ( ) <EOL> class EmailView ( AjaxCapableProcessFormViewMixin , FormView ) : <EOL> template_name = "<STR_LIT>" + app_settings . TEMPLATE_EXTENSION <EOL> form_class = AddEmailForm <EOL> success_url = reverse_lazy ( '<STR_LIT>' ) <EOL> def get_form_class ( self ) : <EOL> return get_form_class ( app_settings . FORMS , '<STR_LIT>' , self . form_class ) <EOL> def dispatch ( self , request , * args , ** kwargs ) : <EOL> sync_user_email_addresses ( request . user ) <EOL> return super ( EmailView , self ) . dispatch ( request , * args , ** kwargs ) <EOL> def get_form_kwargs ( self ) : <EOL> kwargs = super ( EmailView , self ) . get_form_kwargs ( ) <EOL> kwargs [ "<STR_LIT:user>" ] = self . request . user <EOL> return kwargs <EOL> def form_valid ( self , form ) : <EOL> email_address = form . save ( self . request ) <EOL> get_adapter ( self . request ) . add_message ( <EOL> self . request , <EOL> messages . INFO , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT:email>' : form . cleaned_data [ "<STR_LIT:email>" ] } ) <EOL> signals . email_added . send ( sender = self . request . user . __class__ , <EOL> request = self . request , <EOL> user = self . request . user , <EOL> email_address = email_address ) <EOL> return super ( EmailView , self ) . form_valid ( form ) <EOL> def post ( self , request , * args , ** kwargs ) : <EOL> res = None <EOL> if "<STR_LIT>" in request . POST : <EOL> res = super ( EmailView , self ) . post ( request , * args , ** kwargs ) <EOL> elif request . POST . get ( "<STR_LIT:email>" ) : <EOL> if "<STR_LIT>" in request . POST : <EOL> res = self . _action_send ( request ) <EOL> elif "<STR_LIT>" in request . POST : <EOL> res = self . _action_remove ( request ) <EOL> elif "<STR_LIT>" in request . POST : <EOL> res = self . _action_primary ( request ) <EOL> res = res or HttpResponseRedirect ( reverse ( '<STR_LIT>' ) ) <EOL> res = _ajax_response ( request , res ) <EOL> else : <EOL> res = HttpResponseRedirect ( reverse ( '<STR_LIT>' ) ) <EOL> res = _ajax_response ( request , res ) <EOL> return res <EOL> def _action_send ( self , request , * args , ** kwargs ) : <EOL> email = request . POST [ "<STR_LIT:email>" ] <EOL> try : <EOL> email_address = EmailAddress . objects . get ( <EOL> user = request . user , <EOL> email = email , <EOL> ) <EOL> get_adapter ( request ) . add_message ( <EOL> request , <EOL> messages . INFO , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT:email>' : email } ) <EOL> email_address . send_confirmation ( request ) <EOL> return HttpResponseRedirect ( self . get_success_url ( ) ) <EOL> except EmailAddress . DoesNotExist : <EOL> pass <EOL> def _action_remove ( self , request , * args , ** kwargs ) : <EOL> email = request . POST [ "<STR_LIT:email>" ] <EOL> try : <EOL> email_address = EmailAddress . objects . get ( <EOL> user = request . user , <EOL> email = email <EOL> ) <EOL> if email_address . primary : <EOL> get_adapter ( request ) . add_message ( <EOL> request , <EOL> messages . ERROR , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> { "<STR_LIT:email>" : email } ) <EOL> else : <EOL> email_address . delete ( ) <EOL> signals . email_removed . send ( sender = request . user . __class__ , <EOL> request = request , <EOL> user = request . user , <EOL> email_address = email_address ) <EOL> get_adapter ( request ) . add_message ( <EOL> request , <EOL> messages . SUCCESS , <EOL> '<STR_LIT>' , <EOL> { "<STR_LIT:email>" : email } ) <EOL> return HttpResponseRedirect ( self . get_success_url ( ) ) <EOL> except EmailAddress . DoesNotExist : <EOL> pass <EOL> def _action_primary ( self , request , * args , ** kwargs ) : <EOL> email = request . POST [ "<STR_LIT:email>" ] <EOL> try : <EOL> email_address = EmailAddress . objects . get_for_user ( <EOL> user = request . user , <EOL> email = email <EOL> ) <EOL> if not email_address . verified and EmailAddress . objects . filter ( user = request . user , <EOL> verified = True ) . exists ( ) : <EOL> get_adapter ( request ) . add_message ( <EOL> request , <EOL> messages . ERROR , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> else : <EOL> try : <EOL> from_email_address = EmailAddress . objects . get ( user = request . user , primary = True ) <EOL> except EmailAddress . DoesNotExist : <EOL> from_email_address = None <EOL> email_address . set_as_primary ( ) <EOL> get_adapter ( request ) . add_message ( <EOL> request , <EOL> messages . SUCCESS , <EOL> '<STR_LIT>' ) <EOL> signals . email_changed . send ( sender = request . user . __class__ , <EOL> request = request , <EOL> user = request . user , <EOL> from_email_address = from_email_address , <EOL> to_email_address = email_address ) <EOL> return HttpResponseRedirect ( self . get_success_url ( ) ) <EOL> except EmailAddress . DoesNotExist : <EOL> pass <EOL> def get_context_data ( self , ** kwargs ) : <EOL> ret = super ( EmailView , self ) . get_context_data ( ** kwargs ) <EOL> ret [ '<STR_LIT>' ] = ret . get ( '<STR_LIT>' ) <EOL> return ret <EOL> email = login_required ( EmailView . as_view ( ) ) <EOL> class PasswordChangeView ( AjaxCapableProcessFormViewMixin , FormView ) : <EOL> template_name = ( <EOL> "<STR_LIT>" + app_settings . TEMPLATE_EXTENSION ) <EOL> form_class = ChangePasswordForm <EOL> success_url = reverse_lazy ( "<STR_LIT>" ) <EOL> def get_form_class ( self ) : <EOL> return get_form_class ( app_settings . FORMS , <EOL> '<STR_LIT>' , <EOL> self . form_class ) <EOL> @ sensitive_post_parameters_m <EOL> def dispatch ( self , request , * args , ** kwargs ) : <EOL> if not request . user . has_usable_password ( ) : <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' ) ) <EOL> return super ( PasswordChangeView , self ) . dispatch ( request , * args , <EOL> ** kwargs ) <EOL> def get_form_kwargs ( self ) : <EOL> kwargs = super ( PasswordChangeView , self ) . get_form_kwargs ( ) <EOL> kwargs [ "<STR_LIT:user>" ] = self . request . user <EOL> return kwargs <EOL> def form_valid ( self , form ) : <EOL> form . save ( ) <EOL> logout_on_password_change ( self . request , form . user ) <EOL> get_adapter ( self . request ) . add_message ( <EOL> self . request , <EOL> messages . SUCCESS , <EOL> '<STR_LIT>' ) <EOL> signals . password_changed . send ( sender = self . request . user . __class__ , <EOL> request = self . request , <EOL> user = self . request . user ) <EOL> return super ( PasswordChangeView , self ) . form_valid ( form ) <EOL> def get_context_data ( self , ** kwargs ) : <EOL> ret = super ( PasswordChangeView , self ) . get_context_data ( ** kwargs ) <EOL> ret [ '<STR_LIT>' ] = ret . get ( '<STR_LIT>' ) <EOL> return ret <EOL> password_change = login_required ( PasswordChangeView . as_view ( ) ) <EOL> class PasswordSetView ( AjaxCapableProcessFormViewMixin , FormView ) : <EOL> template_name = "<STR_LIT>" + app_settings . TEMPLATE_EXTENSION <EOL> form_class = SetPasswordForm <EOL> success_url = reverse_lazy ( "<STR_LIT>" ) <EOL> def get_form_class ( self ) : <EOL> return get_form_class ( app_settings . FORMS , <EOL> '<STR_LIT>' , <EOL> self . form_class ) <EOL> @ sensitive_post_parameters_m <EOL> def dispatch ( self , request , * args , ** kwargs ) : <EOL> if request . user . has_usable_password ( ) : <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' ) ) <EOL> return super ( PasswordSetView , self ) . dispatch ( request , * args , ** kwargs ) <EOL> def get_form_kwargs ( self ) : <EOL> kwargs = super ( PasswordSetView , self ) . get_form_kwargs ( ) <EOL> kwargs [ "<STR_LIT:user>" ] = self . request . user <EOL> return kwargs <EOL> def form_valid ( self , form ) : <EOL> form . save ( ) <EOL> logout_on_password_change ( self . request , form . user ) <EOL> get_adapter ( self . request ) . add_message ( <EOL> self . request , <EOL> messages . SUCCESS , <EOL> '<STR_LIT>' ) <EOL> signals . password_set . send ( sender = self . request . user . __class__ , <EOL> request = self . request , user = self . request . user ) <EOL> return super ( PasswordSetView , self ) . form_valid ( form ) <EOL> def get_context_data ( self , ** kwargs ) : <EOL> ret = super ( PasswordSetView , self ) . get_context_data ( ** kwargs ) <EOL> ret [ '<STR_LIT>' ] = ret . get ( '<STR_LIT>' ) <EOL> return ret <EOL> password_set = login_required ( PasswordSetView . as_view ( ) ) <EOL> class PasswordResetView ( AjaxCapableProcessFormViewMixin , FormView ) : <EOL> template_name = "<STR_LIT>" + app_settings . TEMPLATE_EXTENSION <EOL> form_class = ResetPasswordForm <EOL> success_url = reverse_lazy ( "<STR_LIT>" ) <EOL> redirect_field_name = "<STR_LIT>" <EOL> def get_form_class ( self ) : <EOL> return get_form_class ( app_settings . FORMS , <EOL> '<STR_LIT>' , <EOL> self . form_class ) <EOL> def form_valid ( self , form ) : <EOL> form . save ( self . request ) <EOL> return super ( PasswordResetView , self ) . form_valid ( form ) <EOL> def get_context_data ( self , ** kwargs ) : <EOL> ret = super ( PasswordResetView , self ) . get_context_data ( ** kwargs ) <EOL> login_url = passthrough_next_redirect_url ( self . request , <EOL> reverse ( "<STR_LIT>" ) , <EOL> self . redirect_field_name ) <EOL> ret [ '<STR_LIT>' ] = ret . get ( '<STR_LIT>' ) <EOL> ret . update ( { "<STR_LIT>" : login_url } ) <EOL> return ret <EOL> password_reset = PasswordResetView . as_view ( ) <EOL> class PasswordResetDoneView ( TemplateView ) : <EOL> template_name = ( <EOL> "<STR_LIT>" + app_settings . TEMPLATE_EXTENSION ) <EOL> password_reset_done = PasswordResetDoneView . as_view ( ) <EOL> class PasswordResetFromKeyView ( AjaxCapableProcessFormViewMixin , FormView ) : <EOL> template_name = ( <EOL> "<STR_LIT>" + app_settings . TEMPLATE_EXTENSION ) <EOL> form_class = ResetPasswordKeyForm <EOL> success_url = reverse_lazy ( "<STR_LIT>" ) <EOL> def get_form_class ( self ) : <EOL> return get_form_class ( app_settings . FORMS , <EOL> '<STR_LIT>' , <EOL> self . form_class ) <EOL> def dispatch ( self , request , uidb36 , key , ** kwargs ) : <EOL> self . request = request <EOL> self . key = key <EOL> token_form = UserTokenForm ( data = { '<STR_LIT>' : uidb36 , '<STR_LIT:key>' : key } ) <EOL> if not token_form . is_valid ( ) : <EOL> self . reset_user = None <EOL> response = self . render_to_response ( <EOL> self . get_context_data ( token_fail = True ) <EOL> ) <EOL> return _ajax_response ( self . request , response , form = token_form ) <EOL> else : <EOL> self . reset_user = token_form . reset_user <EOL> return super ( PasswordResetFromKeyView , self ) . dispatch ( request , <EOL> uidb36 , <EOL> key , <EOL> ** kwargs ) <EOL> def get_form_kwargs ( self ) : <EOL> kwargs = super ( PasswordResetFromKeyView , self ) . get_form_kwargs ( ) <EOL> kwargs [ "<STR_LIT:user>" ] = self . reset_user <EOL> kwargs [ "<STR_LIT>" ] = self . key <EOL> return kwargs <EOL> def form_valid ( self , form ) : <EOL> form . save ( ) <EOL> get_adapter ( self . request ) . add_message ( <EOL> self . request , <EOL> messages . SUCCESS , <EOL> '<STR_LIT>' ) <EOL> signals . password_reset . send ( sender = self . reset_user . __class__ , <EOL> request = self . request , <EOL> user = self . reset_user ) <EOL> if app_settings . LOGIN_ON_PASSWORD_RESET : <EOL> return perform_login ( <EOL> self . request , self . reset_user , <EOL> email_verification = app_settings . EMAIL_VERIFICATION ) <EOL> return super ( PasswordResetFromKeyView , self ) . form_valid ( form ) <EOL> password_reset_from_key = PasswordResetFromKeyView . as_view ( ) <EOL> class PasswordResetFromKeyDoneView ( TemplateView ) : <EOL> template_name = ( <EOL> "<STR_LIT>" + <EOL> app_settings . TEMPLATE_EXTENSION ) <EOL> password_reset_from_key_done = PasswordResetFromKeyDoneView . as_view ( ) <EOL> class LogoutView ( TemplateResponseMixin , View ) : <EOL> template_name = "<STR_LIT>" + app_settings . TEMPLATE_EXTENSION <EOL> redirect_field_name = "<STR_LIT>" <EOL> def get ( self , * args , ** kwargs ) : <EOL> if app_settings . LOGOUT_ON_GET : <EOL> return self . post ( * args , ** kwargs ) <EOL> if not self . request . user . is_authenticated ( ) : <EOL> return redirect ( self . get_redirect_url ( ) ) <EOL> ctx = self . get_context_data ( ) <EOL> return self . render_to_response ( ctx ) <EOL> def post ( self , * args , ** kwargs ) : <EOL> url = self . get_redirect_url ( ) <EOL> if self . request . user . is_authenticated ( ) : <EOL> self . logout ( ) <EOL> return redirect ( url ) <EOL> def logout ( self ) : <EOL> get_adapter ( self . request ) . add_message ( <EOL> self . request , <EOL> messages . SUCCESS , <EOL> '<STR_LIT>' ) <EOL> auth_logout ( self . request ) <EOL> def get_context_data ( self , ** kwargs ) : <EOL> ctx = kwargs <EOL> redirect_field_value = get_request_param ( self . request , <EOL> self . redirect_field_name ) <EOL> ctx . update ( { <EOL> "<STR_LIT>" : self . redirect_field_name , <EOL> "<STR_LIT>" : redirect_field_value } ) <EOL> return ctx <EOL> def get_redirect_url ( self ) : <EOL> return ( <EOL> get_next_redirect_url ( <EOL> self . request , <EOL> self . redirect_field_name ) or get_adapter ( <EOL> self . request ) . get_logout_redirect_url ( <EOL> self . request ) ) <EOL> logout = LogoutView . as_view ( ) <EOL> class AccountInactiveView ( TemplateView ) : <EOL> template_name = ( <EOL> '<STR_LIT>' + app_settings . TEMPLATE_EXTENSION ) <EOL> account_inactive = AccountInactiveView . as_view ( ) <EOL> class EmailVerificationSentView ( TemplateView ) : <EOL> template_name = ( <EOL> '<STR_LIT>' + app_settings . TEMPLATE_EXTENSION ) <EOL> email_verification_sent = EmailVerificationSentView . as_view ( ) </s>
