def test_invalid_token_is_handled(self):
        """there are no explosions in invalid tokens handling"""
        request = MockRequest(self.user)
        token = credentialchange.store_new_credential(request, 'email', '*****@*****.**')

        email = credentialchange.read_new_credential(request, 'em4il', token)
        self.assertIsNone(email)
    def test_valid_token_generation(self):
        """credentialchange module allows for store and read of change token"""
        request = MockRequest(self.user)
        token = credentialchange.store_new_credential(request, 'email', '*****@*****.**')

        email = credentialchange.read_new_credential(request, 'email', token)
        self.assertEqual(email, '*****@*****.**')
Beispiel #3
0
def use_token(request, token):
    new_email = read_new_credential(request, 'email', token)
    if new_email:
        request.user.set_email(new_email)
        request.user.save()
        return Response({'detail': _("Your e-mail has been changed.")})
    else:
        raise ValueError()
Beispiel #4
0
def use_token(request, token):
    new_email = read_new_credential(request, 'email', token)
    if new_email:
        request.user.set_email(new_email)
        request.user.save()
        return Response({'detail': _("Your e-mail has been changed.")})
    else:
        raise ValueError()
    def test_invalid_token_is_handled(self):
        """there are no explosions in invalid tokens handling"""
        request = MockRequest(self.user)
        token = credentialchange.store_new_credential(request, 'email',
                                                      '*****@*****.**')

        email = credentialchange.read_new_credential(request, 'em4il', token)
        self.assertIsNone(email)
    def test_valid_token_generation(self):
        """credentialchange module allows for store and read of change token"""
        request = MockRequest(self.user)
        token = credentialchange.store_new_credential(request, 'email',
                                                      '*****@*****.**')

        email = credentialchange.read_new_credential(request, 'email', token)
        self.assertEqual(email, '*****@*****.**')
Beispiel #7
0
def use_token(request, token):
    new_password = read_new_credential(request, 'password', token)
    if new_password:
        request.user.set_password(new_password)
        request.user.save()
        update_session_auth_hash(request, request.user)
        return Response({'detail': _("Your password has been changed.")})
    else:
        raise ValueError()
Beispiel #8
0
def use_token(request, token):
    new_password = read_new_credential(request, 'password', token)
    if new_password:
        request.user.set_password(new_password)
        request.user.save()
        update_session_auth_hash(request, request.user)
        return Response({'detail': _("Your password has been changed.")})
    else:
        raise ValueError()
    def test_password_change_invalidated_token(self):
        """token is invalidated by password change"""
        request = MockRequest(self.user)
        token = credentialchange.store_new_credential(request, 'email', '*****@*****.**')

        self.user.set_password('Egebeg!123')
        self.user.save()

        email = credentialchange.read_new_credential(request, 'email', token)
        self.assertIsNone(email)
    def test_password_change_invalidated_token(self):
        """token is invalidated by password change"""
        request = MockRequest(self.user)
        token = credentialchange.store_new_credential(request, 'email',
                                                      '*****@*****.**')

        self.user.set_password('Egebeg!123')
        self.user.save()

        email = credentialchange.read_new_credential(request, 'email', token)
        self.assertIsNone(email)
Beispiel #11
0
def confirm_password_change(request, token):
    new_credential = read_new_credential(request, 'password', token)
    if not new_credential:
        raise ChangeError()

    request.user.set_password(new_credential)
    update_session_auth_hash(request, request.user)
    request.user.save(update_fields=['password'])

    message = _("%(user)s, your password has been changed.")
    return render(request, 'misago/options/credentials_changed.html', {
            'message': message % {'user': request.user.username},
        })
Beispiel #12
0
def confirm_password_change(request, token):
    new_credential = read_new_credential(request, 'password', token)
    if not new_credential:
        raise ChangeError()

    request.user.set_password(new_credential)
    update_session_auth_hash(request, request.user)
    request.user.save(update_fields=['password'])

    message = _("%(user)s, your password has been changed.")
    return render(request, 'misago/options/credentials_changed.html', {
            'message': message % {'user': request.user.username},
        })
Beispiel #13
0
def confirm_email_change(request, token):
    new_credential = read_new_credential(request, 'email', token)
    if not new_credential:
        raise ChangeError()

    try:
        request.user.set_email(new_credential)
        request.user.save(update_fields=['email', 'email_hash'])
    except IntegrityError:
        raise ChangeError()

    message = _("%(user)s, your e-mail has been changed.")
    return render(request, 'misago/options/credentials_changed.html', {
            'message': message % {'user': request.user.username},
        })
Beispiel #14
0
def confirm_email_change(request, token):
    new_credential = read_new_credential(request, 'email', token)
    if not new_credential:
        raise ChangeError()

    try:
        request.user.set_email(new_credential)
        request.user.save(update_fields=['email', 'email_hash'])
    except IntegrityError:
        raise ChangeError()

    message = _("%(user)s, your e-mail has been changed.")
    return render(request, 'misago/options/credentials_changed.html', {
            'message': message % {'user': request.user.username},
        })