fix: don't login when code's missing, clear it after use
This commit is contained in:
parent
617a477be9
commit
7bc7a14457
2 changed files with 6 additions and 1 deletions
|
@ -82,7 +82,9 @@ class MinecraftClient:
|
|||
try:
|
||||
await self.authenticator.refresh()
|
||||
self.logger.warning("Refreshed Token")
|
||||
except AuthException:
|
||||
except AuthException as e:
|
||||
if not self.authenticator.code:
|
||||
raise e # no code to login, re-raise refresh exc
|
||||
await self.authenticator.login()
|
||||
self.logger.info("Logged in")
|
||||
self._authenticated = True
|
||||
|
|
|
@ -72,7 +72,10 @@ class MicrosoftAuthenticator(AuthInterface):
|
|||
)
|
||||
|
||||
async def login(self): # TODO nicer way to get code?
|
||||
if not self.code:
|
||||
raise AuthException("/login", 0, {"error": "Missing login code"}, {})
|
||||
self.accessToken = await self.authenticate(self.code)
|
||||
self.code = None # this is only valid once
|
||||
prof = await self.fetch_profile()
|
||||
self.selectedProfile = GameProfile(id=prof['id'], name=prof['name'])
|
||||
logging.info("Successfully logged into Microsoft account")
|
||||
|
|
Loading…
Reference in a new issue