summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Dobrowolski <admin@tastycode.pl>2020-05-30 23:08:52 +0200
committerPiotr Dobrowolski <admin@tastycode.pl>2020-05-30 23:08:52 +0200
commitb17854c5c3f0a0d64c38cc621080147b6d8ec741 (patch)
tree95b3633a71d949e16e91ecfbadc511fddca86ab3
parent64770ea1dab778b56e1acc4252462969471f97e1 (diff)
downloadsso-v2-b17854c5c3f0a0d64c38cc621080147b6d8ec741.tar.gz
sso-v2-b17854c5c3f0a0d64c38cc621080147b6d8ec741.tar.bz2
sso-v2-b17854c5c3f0a0d64c38cc621080147b6d8ec741.tar.xz
sso-v2-b17854c5c3f0a0d64c38cc621080147b6d8ec741.zip
fix token expiration date display
-rw-r--r--sso/models.py5
-rw-r--r--templates/profile.html2
2 files changed, 6 insertions, 1 deletions
diff --git a/sso/models.py b/sso/models.py
index f2208ba..a403a8d 100644
--- a/sso/models.py
+++ b/sso/models.py
@@ -6,6 +6,7 @@ from authlib.integrations.sqla_oauth2 import (
from authlib.oauth2.rfc6749.util import scope_to_list, list_to_scope
from sso.extensions import db
from sso.directory import LDAPUserProxy
+from datetime import datetime
class Client(db.Model, OAuth2ClientMixin):
@@ -53,3 +54,7 @@ class Token(db.Model, OAuth2TokenMixin):
primaryjoin="Token.client_id == Client.client_id",
foreign_keys=[client_id],
)
+
+ @property
+ def expires_at_dt(self):
+ return datetime.fromtimestamp(self.get_expires_at())
diff --git a/templates/profile.html b/templates/profile.html
index ad1d890..3ad2300 100644
--- a/templates/profile.html
+++ b/templates/profile.html
@@ -28,7 +28,7 @@
<td>
{% for scope in token.get_scope().split() %}<code>{{ scope }}</code> {% endfor %}
</td>
- <td>{{ token.get_expires_at() }}</td>
+ <td>{{ token.expires_at_dt }}</td>
<td>
<form class="text-right" method="post" action="{{ url_for('.token_revoke', id=token.id) }}">
{{ csrf_field() }}