コード例 #1
0
    def test_password_reset_email(self, email_mock):
        """load the password reset email"""
        reset = models.PasswordReset.objects.create(user=self.local_user)
        emailing.password_reset_email(reset)

        self.assertEqual(email_mock.call_count, 1)
        args = email_mock.call_args[0]
        self.assertEqual(args[0], "*****@*****.**")
        self.assertEqual(args[1], "Reset your BookWyrm password")
        self.assertEqual(len(args), 4)
コード例 #2
0
ファイル: view_actions.py プロジェクト: SHSauler/bookwyrm
def password_reset_request(request):
    ''' create a password reset token '''
    email = request.POST.get('email')
    try:
        user = models.User.objects.get(email=email)
    except models.User.DoesNotExist:
        return redirect('/password-reset')

    # remove any existing password reset cods for this user
    models.PasswordReset.objects.filter(user=user).all().delete()

    # create a new reset code
    code = models.PasswordReset.objects.create(user=user)
    password_reset_email(code)
    data = {'message': 'Password reset link sent to %s' % email}
    return TemplateResponse(request, 'password_reset_request.html', data)
コード例 #3
0
ファイル: password.py プロジェクト: mmai/bookwyrm
    def post(self, request):
        """ create a password reset token """
        email = request.POST.get("email")
        try:
            user = models.User.objects.get(email=email)
        except models.User.DoesNotExist:
            return redirect("/password-reset")

        # remove any existing password reset cods for this user
        models.PasswordReset.objects.filter(user=user).all().delete()

        # create a new reset code
        code = models.PasswordReset.objects.create(user=user)
        password_reset_email(code)
        data = {"message": "Password reset link sent to %s" % email}
        return TemplateResponse(request, "password_reset_request.html", data)
コード例 #4
0
    def post(self, request):
        """create a password reset token"""
        email = request.POST.get("email")
        try:
            user = models.User.objects.get(email=email, email__isnull=False)
        except models.User.DoesNotExist:
            data = {"error": _("No user with that email address was found.")}
            return TemplateResponse(request, "password_reset_request.html", data)

        # remove any existing password reset cods for this user
        models.PasswordReset.objects.filter(user=user).all().delete()

        # create a new reset code
        code = models.PasswordReset.objects.create(user=user)
        password_reset_email(code)
        data = {"message": _("A password reset link sent to %s" % email)}
        return TemplateResponse(request, "password_reset_request.html", data)