From 3fb1ad507c03d1cb5d751ede31f996f6183c2ce0 Mon Sep 17 00:00:00 2001 From: Calvin Mclean Date: Wed, 22 Aug 2018 11:12:48 -0700 Subject: [PATCH] Do not expire AccessTokens --- api/v2/views/access_token.py | 2 -- core/models/access_token.py | 9 +++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/api/v2/views/access_token.py b/api/v2/views/access_token.py index 28402ac37..f4a0cc2bc 100644 --- a/api/v2/views/access_token.py +++ b/api/v2/views/access_token.py @@ -37,10 +37,8 @@ def create(self, request): user = AtmosphereUser.objects.get(id=atmo_user) access_token = create_access_token(user, name, issuer=issuer_backend) - expireTime = access_token.token.expireTime json_response = { 'token': access_token.token_id, - 'expireTime': expireTime.strftime("%b %d, %Y %H:%M:%S"), 'id': access_token.id, 'name': name } diff --git a/core/models/access_token.py b/core/models/access_token.py index 195e72669..970962b46 100644 --- a/core/models/access_token.py +++ b/core/models/access_token.py @@ -1,9 +1,8 @@ from django.db import models from django.utils import timezone -from django_cyverse_auth.models import Token, get_or_create_token +from django_cyverse_auth.models import Token -from datetime import timedelta class AccessToken(models.Model): """ @@ -17,9 +16,7 @@ class Meta: app_label = "core" def create_access_token(user, token_name=None, token_expire=None, remote_ip=None, issuer=None): - if not token_expire: - token_expire = timezone.now() + timedelta(days=365*5) - - token = get_or_create_token(user, None, token_expire, remote_ip, issuer) + token = Token(user=user) + token.save() access_token, created = AccessToken.objects.update_or_create(token=token, name=token_name) return access_token