Create services not working
Closed this issue · 4 comments
I have error when create service account in admin GUI
Traceback (most recent call last): File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 372, in run_asgi result = await app(self.scope, self.receive, self.send) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__ return await self.app(scope, receive, send) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/fastapi/applications.py", line 261, in __call__ await super().__call__(scope, receive, send) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/applications.py", line 112, in __call__ await self.middleware_stack(scope, receive, send) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 181, in __call__ raise exc File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 159, in __call__ await self.app(scope, receive, _send) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 63, in __call__ response = await self.dispatch_func(request, call_next) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/easyauth/server.py", line 176, in handle_401_403 response = await call_next(request) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 44, in call_next raise app_exc File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 34, in coro await self.app(scope, request.receive, send_stream.send) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 63, in __call__ response = await self.dispatch_func(request, call_next) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/easyauth/server.py", line 172, in detect_token_in_cookie return await call_next(request) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 44, in call_next raise app_exc File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 34, in coro await self.app(scope, request.receive, send_stream.send) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/middleware/cors.py", line 92, in __call__ await self.simple_response(scope, receive, send, request_headers=headers) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/middleware/cors.py", line 147, in simple_response await self.app(scope, receive, send) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/exceptions.py", line 82, in __call__ raise exc File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/exceptions.py", line 71, in __call__ await self.app(scope, receive, sender) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__ raise e File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__ await self.app(scope, receive, send) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/routing.py", line 656, in __call__ await route.handle(scope, receive, send) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/routing.py", line 259, in handle await self.app(scope, receive, send) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/starlette/routing.py", line 61, in app response = await func(request) File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/fastapi/routing.py", line 227, in app raw_response = await run_endpoint_function( File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/fastapi/routing.py", line 160, in run_endpoint_function return await dependant.call(**values) File "<makefun-gen-6>", line 2, in create_service File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/easyauth/router.py", line 171, in mock_function return await result File "/Users/kel/maddevs/collector/easyauth/venv/lib/python3.10/site-packages/easyauth/api.py", line 467, in create_service user_groups = [await verify_group(group) for group in user.groups] NameError: name 'user' is not defined
In the function create_service need to change
from
user_groups = [await verify_group(group) for group in user.groups]
to
service_groups = [await verify_group(group) for group in service.groups]
Hello @akyl0221
Thanks for opening the issue. I will have a look at this when I have some more time. If you are feeling adventurous, feel free to fork, fix & create a PR.
Ok I will do it
I managed to fix the issue. Please review @codemation
Fixed in https://github.com/codemation/easyauth/releases/tag/1.0.20 - nice work @akyl0221