Added login API
This commit is contained in:
parent
20bd4d8ebc
commit
f59a7cd3b0
@ -96,6 +96,7 @@ This provides:
|
||||
|
||||
* `/id/callback/` for OIDC callback
|
||||
* `/id/logout/` for logout
|
||||
* `/id/login/` for login (accepts GET parameters: `next` - redirect to after login, `method` - can be `email` or `student_id`)
|
||||
|
||||
### 2. (Alternative) Use the callback decorator
|
||||
|
||||
|
@ -1,9 +1,14 @@
|
||||
from django.urls import path
|
||||
from django_hopid.views import hopid_logout_view, hopid_callback_view
|
||||
from django_hopid.views import (
|
||||
hopid_logout_view,
|
||||
hopid_login_view,
|
||||
hopid_callback_view
|
||||
)
|
||||
|
||||
app_name = "django_hopid"
|
||||
|
||||
urlpatterns = [
|
||||
path("callback/", hopid_callback_view, name="callback"),
|
||||
path("logout/", hopid_logout_view, name="logout"),
|
||||
path("login/", hopid_login_view, name="login"),
|
||||
]
|
@ -1,7 +1,7 @@
|
||||
from django.shortcuts import redirect
|
||||
from django.contrib.auth import logout as django_logout
|
||||
|
||||
from .utils import get_hopid_logout_url
|
||||
from .utils import get_hopid_logout_url, get_hopid_login_url
|
||||
from .decorators import hopid_callback
|
||||
|
||||
@hopid_callback()
|
||||
@ -9,6 +9,12 @@ def hopid_callback_view(request, *args, **kwargs):
|
||||
next = request.GET.get('next') or '/'
|
||||
return redirect(next)
|
||||
|
||||
def hopid_login_view(request):
|
||||
next = request.GET.get('next') or None
|
||||
method = request.GET.get('method') or None
|
||||
|
||||
return redirect(get_hopid_login_url(request, method, next))
|
||||
|
||||
def hopid_logout_view(request):
|
||||
django_logout(request)
|
||||
return redirect(get_hopid_logout_url())
|
||||
|
Loading…
x
Reference in New Issue
Block a user