def recover_password(email): """ Method that recovers the password of a given credential :param email: email of the credential to be changed """ try: credential = Credential.objects.get(email=email) except ObjectDoesNotExist: raise ValidationError(f"No account found with the email {email}!") password = Utils.generate_random_password() credential.password = make_password(password) credential.save() # TODO: Send email with new "password" print(f"NEW PASSWORD: {password}")
def add_credential(email): """ Method create a new credential :param password: State name :return: Credential created id """ password = Utils.generate_random_password() new_credential = Credential.objects.create( password=make_password(password), email=email) new_credential.save() # TODO: Send email with "password" print(f"PASSWORD: {password}") return new_credential.id