Store access token id in session data

This commit is contained in:
Yohann D'ANELLO 2021-11-04 14:25:35 +01:00
parent d3c2441111
commit 41435a6838
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 6 additions and 0 deletions

View File

@ -202,6 +202,10 @@ class AccessToken(models.Model):
return user return user
@classmethod
def get_token(cls, request):
return AccessToken.objects.get(pk=request.session['access_token_id'])
class Meta: class Meta:
verbose_name = _('access token') verbose_name = _('access token')
verbose_name_plural = _('access tokens') verbose_name_plural = _('access tokens')

View File

@ -37,6 +37,8 @@ class AuthorizeView(RedirectView):
datetime.fromtimestamp(token['expires_at'])), datetime.fromtimestamp(token['expires_at'])),
) )
user = token_obj.fetch_user(True) user = token_obj.fetch_user(True)
self.request.session['access_token_id'] = token_obj.id
self.request.session.save()
login(self.request, user) login(self.request, user)
return reverse('index') return reverse('index')