Implement login ?next=
This commit is contained in:
parent
4638a71cfb
commit
eb01c38914
@ -1,5 +1,5 @@
|
|||||||
# Society Self-Service
|
# 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
|
# 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
|
# 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.shortcuts import render, redirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
return redirect(reverse('splash'))
|
return redirect(reverse('splash'))
|
||||||
return render(request, 'ssmain/index.html')
|
return render(request, 'ssmain/index.html')
|
||||||
|
|
||||||
def login(request):
|
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):
|
def logout(request):
|
||||||
auth_logout(request)
|
auth_logout(request)
|
||||||
|
Loading…
Reference in New Issue
Block a user