Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
7c9cae9d
Commit
7c9cae9d
authored
Sep 02, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Automatically redirect to login backend if there is only one
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
de8ac894
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletion
+11
-1
weblate/accounts/views.py
weblate/accounts/views.py
+11
-1
No files found.
weblate/accounts/views.py
View file @
7c9cae9d
...
...
@@ -33,6 +33,7 @@ from django.contrib.auth.models import User
from
django.contrib.auth
import
views
as
auth_views
from
django.views.generic
import
TemplateView
from
django.contrib.auth
import
update_session_auth_hash
from
django.core.urlresolvers
import
reverse
from
urllib
import
urlencode
...
...
@@ -372,13 +373,18 @@ def weblate_login(request):
if
request
.
user
.
is_authenticated
():
return
redirect
(
'profile'
)
# Redirect if there is only one backend
auth_backends
=
load_backends
(
BACKENDS
).
keys
()
if
len
(
auth_backends
)
==
1
:
return
redirect
(
'social:begin'
,
auth_backends
[
0
])
return
auth_views
.
login
(
request
,
template_name
=
'accounts/login.html'
,
authentication_form
=
LoginForm
,
extra_context
=
{
'login_backends'
:
[
x
for
x
in
load_backends
(
BACKENDS
).
keys
()
if
x
!=
'email'
x
for
x
in
auth_backends
if
x
!=
'email'
],
'title'
:
_
(
'Login'
),
}
...
...
@@ -416,6 +422,10 @@ def register(request):
backends
=
set
(
load_backends
(
BACKENDS
).
keys
())
# Redirect if there is only one backend
if
len
(
backends
)
==
1
:
return
redirect
(
'social:begin'
,
backends
.
pop
())
return
render
(
request
,
'accounts/register.html'
,
...
...
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