<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 async def check_user(self, request, func=None, location=None, **kwargs):
 """Check for user is logged and pass the given func. :param func: user checker function, defaults to default_user_checker :param location: where to redirect if user is not logged in. May be either string (URL) or function which accepts request as argument and returns string URL. """

        user = await self.load_user(request)
        func = func or self.cfg.default_user_checker
        if not func(user):
            location = location or self.cfg.login_url
            while callable(location):
                location = location(request)
                while asyncio.iscoroutine(location):
                    location = await location
            raise HTTPFound(location, **kwargs)
        return user