Beispiel #1
0
 def form_valid(self, form):
     form.save()
     # Updating the password logs out all other sessions for the user
     # except the current one.
     update_session_auth_hash(self.request, form.user)
     logging.getLogger("info_logger").info(
         self.log_message.format(self.request.user.rut,
                                 get_client_ip(self.request)))
     return super().form_valid(form)
Beispiel #2
0
 def form_valid(self, form):
     request = self.request
     rut = form.cleaned_data.get("rut")
     password = form.cleaned_data.get("password")
     user = authenticate(request, username=rut, password=password)
     if user is not None:
         login(request, user)
         logging.getLogger("info_logger").info(
             self.log_message.format(user.rut, get_client_ip(self.request)))
         return redirect("/")
     return super(LoginView, self).form_invalid(form)
Beispiel #3
0
 def form_valid(self, form):
     user = form.save()
     self.__confirmation_email_sender(user)
     logging.getLogger("info_logger").info(
         self.log_message.format(user.rut, get_client_ip(self.request)))
     super().form_valid(form)
     return render(
         self.request, 'common/redirect.html', {
             'message': 'Debe validar su dirección de correo.',
             'url_redirect': resolve_url('common:login')
         })
Beispiel #4
0
 def get(self, request, uidb64, token, *args, **kwargs):
     try:
         uid = force_text(urlsafe_base64_decode(uidb64))
         user = User.objects.get(pk=uid)
         user_email = user.confirm_email(token)
     except (TypeError, ValueError, OverflowError, User.DoesNotExist):
         user = None
     if user is not None and user.is_confirmed:
         user.is_active = True
         user.save()
         login(request, user)
         logging.getLogger("info_logger").info(
             self.log_message.format(user.rut, get_client_ip(self.request)))
         return render(
             request, 'common/redirect.html', {
                 'message': 'Su cuenta ha sido activada.',
                 'url_redirect': resolve_url('core:home')
             })
     else:
         logging.getLogger("error_logger").error(
             self.log_message.format(None, get_client_ip(self.request)))
         return HttpResponse('Enlace de activación inválido!')
Beispiel #5
0
 def form_invalid(self, form):
     rut = form.cleaned_data.get("rut")
     logging.getLogger("error_logger").error(
         self.log_message.format(rut, get_client_ip(self.request)))
     return super().form_invalid(form)
Beispiel #6
0
 def dispatch(self, request, *args, **kwargs):
     if not request.user.is_authenticated:
         logging.getLogger("error_logger").error(
             self.log_message.format(request.user, get_client_ip(request)))
     return super().dispatch(request, *args, **kwargs)
Beispiel #7
0
 def get(self, request, *args, **kwargs):
     logging.getLogger("info_logger").info(
         self.log_message.format(request.user.rut, get_client_ip(request)))
     return render(request, self.template_name)