Implement login ?next=

This commit is contained in:
Yingtong Li 2019-01-25 10:31:15 +11:00
parent 4638a71cfb
commit eb01c38914
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -1,5 +1,5 @@
# Society Self-Service
# Copyright © 2018 Yingtong Li (RunasSudo)
# Copyright © 2018-2019 Yingtong Li (RunasSudo)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@ -21,13 +21,18 @@ from django.http import HttpResponse
from django.shortcuts import render, redirect
from django.urls import reverse
import urllib.parse
def index(request):
if request.user.is_authenticated:
return redirect(reverse('splash'))
return render(request, 'ssmain/index.html')
def login(request):
return redirect(reverse('social:begin', args=['google-oauth2']))
baseurl = reverse('social:begin', args=['google-oauth2'])
if 'next' in request.GET:
baseurl += '?' + urllib.parse.urlencode({'next': request.GET['next']})
return redirect(baseurl)
def logout(request):
auth_logout(request)