Store access token id in session data
This commit is contained in:
parent
d3c2441111
commit
41435a6838
|
@ -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')
|
||||||
|
|
|
@ -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')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue