Commit 2fa80706 authored by Michal Čihař's avatar Michal Čihař

Handle toke expiry in timezone aware timestamp

Issue #892
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent fd988745
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
from datetime import datetime, timedelta from datetime import timedelta
from django.utils import timezone
from weblate.trans.machine.base import ( from weblate.trans.machine.base import (
MachineTranslation, MachineTranslationError, MissingConfiguration MachineTranslation, MachineTranslationError, MissingConfiguration
) )
...@@ -62,7 +63,7 @@ class MicrosoftTranslation(MachineTranslation): ...@@ -62,7 +63,7 @@ class MicrosoftTranslation(MachineTranslation):
''' '''
Checks whether token is about to expire. Checks whether token is about to expire.
''' '''
return self._token_expiry <= datetime.now() return self._token_expiry <= timezone.now()
@property @property
def access_token(self): def access_token(self):
...@@ -87,7 +88,7 @@ class MicrosoftTranslation(MachineTranslation): ...@@ -87,7 +88,7 @@ class MicrosoftTranslation(MachineTranslation):
) )
self._access_token = data['access_token'] self._access_token = data['access_token']
self._token_expiry = datetime.now() + TOKEN_EXPIRY self._token_expiry = timezone.now() + TOKEN_EXPIRY
return self._access_token return self._access_token
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment