def user_details(*args, **kwargs):
    return {
        "email": "*****@*****.**",
        "password": Utility.get_password_hash("welcome@1"),
        "first_name": "integration",
        "last_name": "test",
        "status": True,
        "bot": "integration",
        "account": 1,
        "is_integration_user": False,
    }
Beispiel #2
0
    def add_user(
        email: str,
        password: str,
        first_name: str,
        last_name: str,
        account: int,
        bot: str,
        user: str,
        is_integration_user=False,
        role="trainer",
    ):
        """
        adds new user to the account

        :param email: user login id
        :param password: user password
        :param first_name: user firstname
        :param last_name:  user lastname
        :param account: account id
        :param bot: bot id
        :param user: user id
        :param is_integration_user: is this
        :param role: user role
        :return: user details
        """
        if (Utility.check_empty_string(email)
                or Utility.check_empty_string(last_name)
                or Utility.check_empty_string(first_name)
                or Utility.check_empty_string(password)):
            raise AppException(
                "Email, FirstName, LastName and password cannot be empty or blank spaces"
            )

        Utility.is_exist(
            User,
            exp_message=
            "User already exists! try with different email address.",
            email__iexact=email.strip(),
            status=True,
        )
        return (User(
            email=email.strip(),
            password=Utility.get_password_hash(password.strip()),
            first_name=first_name.strip(),
            last_name=last_name.strip(),
            account=account,
            bot=bot.strip(),
            user=user.strip(),
            is_integration_user=is_integration_user,
            role=role.strip(),
        ).save().to_mongo().to_dict())
Beispiel #3
0
    async def overwrite_password(token: str, password: str):
        """
        Changes the user's password

        :param token: unique token from the password reset page
        :param password: new password entered by the user
        :return: mail id, mail subject and mail body
        """
        if Utility.check_empty_string(password):
            raise AppException("password cannot be empty or blank")
        email = Utility.verify_token(token)
        user = User.objects().get(email=email)
        user.password = Utility.get_password_hash(password.strip())
        user.user = email
        user.timestamp = datetime.utcnow
        user.save()
        subject = Utility.email_conf['email']['templates'][
            'password_changed_subject']
        body = Utility.email_conf['email']['templates'][
            'password_changed_body']
        return email, subject, body