55import CatchThemAll
66import Ice
77
8- from .user_id_resolver import UserIdResolver
98from .store import PokeStore
9+ from .user_id_resolver import UserIdResolver
1010
1111
1212class SharedPokeBox (CatchThemAll .PokeBox ):
1313 """
1414 SharedPokeBox is an Ice servant that implements Slice interface PokeBox. The same shared servant
15- implements all PokeBox objects; this is doable because all the state is stored in the IPokeStore .
15+ implements all PokeBox objects; this is doable because all the state is stored in the PokeStore .
1616 """
1717
1818 def __init__ (self , pokeStore : PokeStore , userIdResolver : UserIdResolver ):
@@ -43,7 +43,7 @@ def caught(self, pokemon: list[str], current: Ice.Current) -> None:
4343 """
4444 Add new Pokémon to the Pokémon collection for the user associated with the current session.
4545 """
46- userId = self .getUserId (current )
46+ userId = self .getUserId (current . id . name )
4747
4848 # Retrieve the existing collection for the user and add the new Pokémon.
4949 savedPokemon = list (self ._pokeStore .retrieveCollection (userId ) or [])
@@ -57,9 +57,8 @@ def caught(self, pokemon: list[str], current: Ice.Current) -> None:
5757 def releaseAll (self , current : Ice .Current ) -> None :
5858 self ._pokeStore .saveCollection (self .getUserId (current ), [])
5959
60- @override
61- def getUserId (self , current : Ice .Current ) -> str :
62- userId = self ._userIdResolver .getUserId (current .id .name )
60+ def getUserId (self , token : str ) -> str :
61+ userId = self ._userIdResolver .getUserId (token )
6362 if userId is None :
6463 raise Ice .DispatchException (Ice .ReplyStatus .Unauthorized .value , "Invalid session token" )
6564 return userId
0 commit comments