auth_service.py 606 B

12345678910111213141516171819202122
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. from app.admin.schema.token import GetLoginToken
  4. from app.admin.schema.auth import AuthGenTokenParam
  5. from common.security.jwt_call_center import create_access_token
  6. class AuthService:
  7. async def gen_token(
  8. self, pk: int
  9. ) -> GetLoginToken:
  10. user_id = pk
  11. a_token = await create_access_token(str(user_id))
  12. data = GetLoginToken(
  13. access_token=a_token.access_token,
  14. access_token_expire_time=a_token.access_token_expire_time,
  15. )
  16. return data
  17. auth_service: AuthService = AuthService()