Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
test-it
test_oauth2_django
Commits
b0347c60
Commit
b0347c60
authored
Nov 06, 2017
by
Sharad Heft
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly handle disallowed logins.
parent
07cde8cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
test_oauth/views.py
test_oauth/views.py
+7
-2
No files found.
test_oauth/views.py
View file @
b0347c60
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'
,
'/'
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment