def test_create_new_user_and_delete(self): max_uid = utils.get_max_uid() self.assertEquals(max_uid, 31337) success, uid_num = utils.create_new_user( "pnunez1", "Phillip E. Nunez", "*****@*****.**", 3116969, "il0vedangengdg!", ) self.assertTrue(success) self.assertEquals(uid_num, 31338) self.assertTrue(utils.user_exists("pnunez1")) success = utils.delete_user("pnunez1") self.assertTrue(success) self.assertFalse(utils.user_exists("pnunez1"))
def clean(self): cleaned_data = super().clean() if (not cleaned_data.get("photo")) + ( not cleaned_data.get("photo_url")) == 0: raise forms.ValidationError( "Please specify up to one of 'Photo 1' or 'Photo 1 URL'") if (not cleaned_data.get("photo2")) + ( not cleaned_data.get("photo2_url")) == 0: raise forms.ValidationError( "Please specify up to one of 'Photo 2' or 'Photo 2 URL'") username = cleaned_data.get("username") if not user_exists(username): raise forms.ValidationError(f"User {username} is not in LDAP") return cleaned_data
def get(self, request, uid, token): print(uid, token) if not user_exists(uid): user = None else: user = uid # getting here just need to get back the pass if user is not None and account_activation_token.check_token( user, token): form = PasswordResetForm() context = {"form": form, "uid": uid, "token": token} return render(request, "password_reset/resetpasswordconfirm.html", context) else: print("invalid link") return redirect(REDIRECT)
def validate_username_not_in_use(value): if user_exists(value): raise ValidationError(f"Username {value} is taken")