Exemple #1
0
    async def create_user(
        self,
        *,
        name: str,
        email: str,
        password: str,
        date_of_birth: str,
        phone_number: str,
        address: str,
        pet_owner: bool,
    ) -> UserInDB:
        user = UserInDB(name=name,
                        email=email,
                        date_of_birth=date_of_birth,
                        address=address,
                        pet_owner=pet_owner,
                        phone_number=phone_number)
        user.change_password(password)

        async with self.connection.transaction():
            user_row = await queries.create_new_user(
                self.connection,
                name=user.name,
                email=user.email,
                salt=user.salt,
                phone_number=user.phone_number,
                address=user.address,
                pet_owner=user.pet_owner,
                date_of_birth=datetime.datetime.strptime(
                    user.date_of_birth, '%d.%m.%Y'),
                hashed_password=user.hashed_password,
            )

        return user.copy(update=dict(user_row))
Exemple #2
0
    async def create_user(self, *, username: str, email: str,
                          password: str) -> UserInDB:
        user = UserInDB(username=username, email=email)
        user.change_password(password)
        user_row = await self._log_and_fetch_row(INSERT_USER_QUERY,
                                                 user.username, user.email,
                                                 user.salt,
                                                 user.hashed_password)

        return user.copy(update=dict(user_row))
Exemple #3
0
    async def create_user(self, *, username: str, email: str,
                          password: str) -> UserInDB:
        user = UserInDB(username=username, email=email)
        user.change_password(password)

        async with self.connection.transaction():
            user_row = await self._log_and_fetch_row(
                CREATE_USER_QUERY,
                user.username,
                user.email,
                user.salt,
                user.hashed_password,
            )

        return user.copy(update=dict(user_row))
    async def create_user(
        self, *, username: str, email: str, password: str,
    ) -> UserInDB:
        user = UserInDB(username=username, email=email)
        user.change_password(password)

        async with self.connection.transaction():
            user_row = await queries.create_new_user(
                self.connection,
                username=user.username,
                email=user.email,
                salt=user.salt,
                hashed_password=user.hashed_password,
            )

        return user.copy(update=dict(user_row))
Exemple #5
0
    async def get_user_by_username(self, *, username: str) -> UserInDB:
        user_row = await self._log_and_fetch_row(FIND_BY_USERNAME, username)
        if user_row:
            return UserInDB(**user_row)

        raise EntityDoesNotExist(
            "user with username {0} does not exist".format(username))
Exemple #6
0
    async def get_user_by_email(self, *, email: str) -> UserInDB:
        user_row = await self._log_and_fetch_row(FIND_BY_EMAIL, email)
        if user_row:
            return UserInDB(**user_row)

        raise EntityDoesNotExist(
            "user with email {0} does not exist".format(email))
Exemple #7
0
    async def get_user_by_email(self, *, email: str) -> UserInDB:
        user_row = await queries.get_user_by_email(self.connection,
                                                   email=email)
        if user_row:
            return UserInDB(**user_row)

        raise EntityDoesNotExist(
            "user with email {0} does not exist".format(email))
Exemple #8
0
    async def get_user_by_name(self, *, name: str) -> UserInDB:
        user_row = await queries.get_user_by_name(
            self.connection,
            name=name,
        )
        if user_row:
            return UserInDB(**user_row)

        raise EntityDoesNotExist(
            "user with name {0} does not exist".format(name), )