This commit is contained in:
Paulus Schoutsen 2018-09-28 15:16:41 +02:00
parent 4f26935756
commit a1e4b98fa8
2 changed files with 11 additions and 3 deletions

View file

@ -2,6 +2,7 @@
from collections import OrderedDict from collections import OrderedDict
from datetime import timedelta from datetime import timedelta
import hmac import hmac
from logging import getLogger
from typing import Any, Dict, List, Optional # noqa: F401 from typing import Any, Dict, List, Optional # noqa: F401
import uuid import uuid
@ -325,6 +326,13 @@ class AuthStore:
)) ))
for rt_dict in data['refresh_tokens']: for rt_dict in data['refresh_tokens']:
created_at = dt_util.parse_datetime(rt_dict['created_at'])
if created_at is None:
getLogger(__name__).error(
'Ignoring refresh token %(id)s with invalid created_at '
'%(created_at)s for user_id %(user_id)s', rt_dict)
continue
last_used_at_str = rt_dict['last_used_at'] last_used_at_str = rt_dict['last_used_at']
if last_used_at_str: if last_used_at_str:
last_used_at = dt_util.parse_datetime(last_used_at_str) last_used_at = dt_util.parse_datetime(last_used_at_str)
@ -338,7 +346,7 @@ class AuthStore:
client_name=rt_dict['client_name'], client_name=rt_dict['client_name'],
client_icon=rt_dict['client_icon'], client_icon=rt_dict['client_icon'],
token_type=rt_dict['token_type'], token_type=rt_dict['token_type'],
created_at=dt_util.parse_datetime(rt_dict['created_at']), created_at=created_at,
access_token_expiration=timedelta( access_token_expiration=timedelta(
seconds=rt_dict['access_token_expiration']), seconds=rt_dict['access_token_expiration']),
token=rt_dict['token'], token=rt_dict['token'],

View file

@ -2,7 +2,7 @@
import asyncio import asyncio
import logging import logging
import os import os
from typing import Dict, Optional, Callable from typing import Dict, Optional, Callable, Any
from homeassistant.const import EVENT_HOMEASSISTANT_STOP from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.core import callback from homeassistant.core import callback
@ -63,7 +63,7 @@ class Store:
"""Return the config path.""" """Return the config path."""
return self.hass.config.path(STORAGE_DIR, self.key) return self.hass.config.path(STORAGE_DIR, self.key)
async def async_load(self): async def async_load(self) -> Optional[Dict[str, Any]]:
"""Load data. """Load data.
If the expected version does not match the given version, the migrate If the expected version does not match the given version, the migrate