Commit b0347c60 authored by Sharad Heft's avatar Sharad Heft
Browse files

Correctly handle disallowed logins.

parent 07cde8cf
from django.shortcuts import redirect
from django.contrib import auth
from django.contrib import auth, messages
from django.views.decorators.cache import never_cache
from django.conf import settings
......@@ -29,6 +29,11 @@ def callback(request):
.fetch_token(code=request.GET['code'])
)
auth.login(request, auth.authenticate(token=token))
user = auth.authenticate(token=token)
if user is not None:
auth.login(request, user)
else:
messages.error(request, 'Login failed.')
return redirect(getattr(settings, 'TEST_OAUTH_REDIRECT', '/'))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment