Ejemplo n.º 1
0
def perform_user_deleted(client, user_data, new_email, request):
    user = create_deleted_test_user(user_data)
    client.force_login(user)
    user.emails.all().delete()
    create_change_email_confirmation(user, new_email)
    assert user.emails.count() == 1
    url = re.findall('(?<=href=").+?(?=")', user.emails.first().body)[0]
    perform_failed_email_change(client, user, url, request)
Ejemplo n.º 2
0
def perform_user_banned_until_expired(client, user_data, new_email, request):
    user = create_banned_until_activated_test_user(user_data, seconds=1)
    client.force_login(user)
    user.emails.all().delete()
    create_change_email_confirmation(user, new_email)
    assert user.emails.count() == 1
    url = re.findall('(?<=href=").+?(?=")', user.emails.first().body)[0]
    sleep(1)
    perform_successful_email_change(client, user, new_email, url, request)
Ejemplo n.º 3
0
def perform_expired_tokens(client, user_data, new_email, request):
    user = create_activated_test_user(user_data)
    client.force_login(user)
    user.emails.all().delete()
    create_change_email_confirmation(user, new_email)
    assert user.emails.count() == 1
    url = re.findall('(?<=href=").+?(?=")', user.emails.first().body)[0]
    expiration_time = settings.CHANGE_EMAIL_EXPIRATION_TIME
    settings.CHANGE_EMAIL_EXPIRATION_TIME = 0
    sleep(1)
    perform_failed_email_change(client, user, url, request)
    settings.CHANGE_EMAIL_EXPIRATION_TIME = expiration_time
Ejemplo n.º 4
0
    def save(self, commit=True):
        profile_pic = self.cleaned_data.get('profile_pic')

        if profile_pic and profile_pic != UserModel.DEFAULT_PROFILE_PIC:
            resized_img(profile_pic, self.instance.profile_pic.file,
                        settings.PROFILE_PIC_SIZE)

        user = super().save(commit=False)
        new_password = self.cleaned_data['new_password']

        if new_password:
            user.set_password(new_password)

        if commit:
            user.save()
            self.email_changed = create_change_email_confirmation(
                user, self.cleaned_data['new_email'])

        return user