Beispiel #1
0
def user_details(*args, **kwargs):
    pytest.bot = "integration"
    return {
        "email": "*****@*****.**",
        "password": Utility.get_password_hash("welcome@1"),
        "first_name": "integration",
        "last_name": "test",
        "status": True,
        "bot": [pytest.bot],
        "account": 1,
        "is_integration_user": False,
    }
Beispiel #2
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(email__iexact=email, status=True).get()
        UserActivityLogger.is_password_reset_within_cooldown_period(email)
        user.password = Utility.get_password_hash(password.strip())
        user.user = email
        user.save()
        UserActivityLogger.add_log(
            account=user['account'],
            email=email,
            a_type=UserActivityType.reset_password.value)
        return email, user.first_name
Beispiel #3
0
    def add_user(
        email: str,
        password: str,
        first_name: str,
        last_name: str,
        account: int,
        user: str,
    ):
        """
        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 user: user id
        :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,
                     user=user.strip()).save().to_mongo().to_dict())