예제 #1
0
    def reset_password(self, event, user=None):
        from pretalx.common.mail import mail

        with transaction.atomic():
            self.pw_reset_token = get_random_string(32)
            self.pw_reset_time = now()
            self.save()
            mail(
                self,
                _('Password recovery'),
                event.settings.mail_text_reset,
                {
                    'name': self.name or '',
                    'event': event.name,
                    'url': build_absolute_uri(
                        'cfp:event.recover',
                        event=event,
                        kwargs={'event': event.slug, 'token': self.pw_reset_token},
                    ),
                },
                event,
                locale=get_language(),
            )
            self.log_action(
                action='pretalx.user.password.reset', person=user, orga=bool(user)
            )
예제 #2
0
    def reset_password(self, event, user=None):
        from pretalx.common.mail import mail
        self.pw_reset_token = get_random_string(32)
        self.pw_reset_time = now()
        self.save()

        if event:
            mail_text = event.settings.mail_text_reset
            context = {
                'name':
                self.name or '',
                'event':
                event.name,
                'url':
                build_absolute_uri(
                    'cfp:event.recover',
                    event=event,
                    kwargs={
                        'event': event.slug,
                        'token': self.pw_reset_token
                    },
                ),
            }
        else:
            context = {
                'name':
                self.name or '',
                'url':
                build_absolute_uri(
                    'orga:auth.recover',
                    kwargs={'token': self.pw_reset_token},
                ),
            }
            mail_text = _('''Hi {name},

you have requested a new password for your pretalx account.
To reset your password, click on the following link:

  {url}

If this wasn\'t you, you can just ignore this email.

All the best,
the pretalx robot''')

        mail(
            self,
            _('Password recovery'),
            mail_text,
            context,
            event,
            locale=get_language(),
        )
        self.log_action(action='pretalx.user.password.reset',
                        person=user,
                        orga=bool(user))
예제 #3
0
파일: auth.py 프로젝트: bogdanap/pretalx
    def form_valid(self, form):
        user = form.cleaned_data['user']

        if not user:
            messages.success(self.request, phrases.cfp.auth_password_reset)
            return redirect(
                reverse('cfp:event.login',
                        kwargs={'event': self.request.event.slug}))

        if user.pw_reset_time and (
                now() - user.pw_reset_time).total_seconds() < 3600 * 24:
            messages.error(self.request, phrases.cfp.auth_already_requested)
            return redirect(
                reverse('cfp:event.reset',
                        kwargs={'event': self.request.event.slug}))

        try:
            user.pw_reset_token = get_random_string(32)
            user.pw_reset_time = now()
            user.save()
            mail(user,
                 _('Password recovery'),
                 self.request.event.settings.mail_text_reset, {
                     'name':
                     user.name or user.nick,
                     'event':
                     self.request.event.name,
                     'url':
                     build_absolute_uri('cfp:event.recover',
                                        event=self.request.event,
                                        kwargs={
                                            'event': self.request.event.slug,
                                            'token': user.pw_reset_token,
                                        })
                 },
                 self.request.event,
                 locale=get_language())
        except SendMailException:
            messages.error(self.request, phrases.base.error_sending_mail)
            return self.get(self.request, *self.args, **self.kwargs)

        messages.success(self.request, phrases.cfp.auth_password_reset)
        user.log_action('pretalx.user.password.reset')

        return redirect(
            reverse('cfp:event.login',
                    kwargs={'event': self.request.event.slug}))
예제 #4
0
    def form_valid(self, form):
        user = form.cleaned_data['user']

        if user.pw_reset_time and (now() - user.pw_reset_time).total_seconds() < 3600 * 24:
            messages.error(self.request, _('You already requested a new password within the last 24 hours.'))
            return redirect(reverse('cfp:event.reset', kwargs={
                'event': self.request.event.slug
            }))

        try:
            user.pw_reset_token = get_random_string(32)
            user.pw_reset_time = now()
            user.save()
            mail(
                user,
                _('Password recovery'),
                self.request.event.settings.mail_text_reset,
                {
                    'name': user.name or user.nick,
                    'event': self.request.event.name,
                    'url': build_absolute_uri(
                        'cfp:event.recover', kwargs={
                            'event': self.request.event.slug,
                            'token': user.pw_reset_token,
                        }
                    )
                },
                self.request.event,
                locale=get_language()
            )
        except SendMailException:
            messages.error(self.request, _('There was an error sending the mail. Please try again later.'))
            return self.get(self.request, *self.args, **self.kwargs)

        messages.success(self.request, _('We will send you an e-mail containing further instructions. If you don\'t '
                                         'see the email within the next minutes, check your spam inbox!'))
        user.log_action('pretalx.user.password.reset')

        return redirect(reverse('cfp:event.login', kwargs={
            'event': self.request.event.slug
        }))
예제 #5
0
 def reset_password(self, event):
     from pretalx.common.mail import mail
     with transaction.atomic():
         self.pw_reset_token = get_random_string(32)
         self.pw_reset_time = now()
         self.save()
         mail(self,
              _('Password recovery'),
              event.settings.mail_text_reset, {
                  'name':
                  self.name or self.nick,
                  'event':
                  event.name,
                  'url':
                  build_absolute_uri('cfp:event.recover',
                                     event=event,
                                     kwargs={
                                         'event': event.slug,
                                         'token': self.pw_reset_token,
                                     })
              },
              event,
              locale=get_language())