This commit is contained in:
parent
be039e7376
commit
00dff24767
8 changed files with 1208 additions and 843 deletions
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime, UTC
|
||||
|
||||
from ocpp.v201.datatypes import IdTokenInfoType
|
||||
from ocpp.v201.enums import AuthorizationStatusType
|
||||
from ocpp.v201.enums import AuthorizationStatusEnumType
|
||||
|
||||
from app.database import SessionLocal
|
||||
from app.models.id_token import IdToken
|
||||
|
@ -11,14 +11,14 @@ async def get_id_token_info(chargepoint_id: str, id_token: str):
|
|||
owner_id = None
|
||||
if id_token["type"] not in ["ISO14443", "ISO15693"]:
|
||||
return IdTokenInfoType(
|
||||
status=AuthorizationStatusType.invalid
|
||||
status=AuthorizationStatusEnumType.invalid
|
||||
), owner_id
|
||||
|
||||
with SessionLocal() as db:
|
||||
db_id_token = db.query(IdToken).filter(IdToken.token == id_token["id_token"]).first()
|
||||
if db_id_token == None:
|
||||
id_token_info = IdTokenInfoType(
|
||||
status=AuthorizationStatusType.unknown
|
||||
status=AuthorizationStatusEnumType.unknown
|
||||
)
|
||||
db_chargepoint = db.query(ChargePoint).filter(ChargePoint.identity == chargepoint_id).first()
|
||||
# Learn token if requested
|
||||
|
@ -32,7 +32,7 @@ async def get_id_token_info(chargepoint_id: str, id_token: str):
|
|||
db.add(db_id_token)
|
||||
|
||||
id_token_info=IdTokenInfoType(
|
||||
status=AuthorizationStatusType.accepted
|
||||
status=AuthorizationStatusEnumType.accepted
|
||||
)
|
||||
owner_id = db_id_token.owner_id
|
||||
db_chargepoint.learn_user_id = None
|
||||
|
@ -42,10 +42,10 @@ async def get_id_token_info(chargepoint_id: str, id_token: str):
|
|||
owner_id = db_id_token.owner_id
|
||||
if db_id_token.is_active == False:
|
||||
id_token_info=IdTokenInfoType(
|
||||
status=AuthorizationStatusType.blocked
|
||||
status=AuthorizationStatusEnumType.blocked
|
||||
)
|
||||
else:
|
||||
id_token_info=IdTokenInfoType(
|
||||
status=AuthorizationStatusType.accepted
|
||||
status=AuthorizationStatusEnumType.accepted
|
||||
)
|
||||
return id_token_info, owner_id
|
Loading…
Add table
Add a link
Reference in a new issue