def test_secret(self): """ Make sure that secret fields are omitted from the response when requested. """ user = BaseUser(username="******", password="******") user.save().run_sync() user_dict = BaseUser.select(exclude_secrets=True).first().run_sync() self.assertTrue("password" not in user_dict.keys())
def get(self, request): data = (SessionsBase.select(SessionsBase.user_id).where( SessionsBase.token == request.cookies.get( "id")).first().run_sync()) if data: session_user = (BaseUser.select( BaseUser.username).where(BaseUser._meta.primary_key == data["user_id"]).first().run_sync()) return PlainTextResponse(f"hello {session_user['username']}") else: return PlainTextResponse("hello world")