Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
8cccbc87
Commit
8cccbc87
authored
Jan 08, 2014
by
Kostas Papadimitriou
Browse files
astakos: Handle invalid provider ids
parent
765b04f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
snf-astakos-app/astakos/im/auth_providers.py
View file @
8cccbc87
...
...
@@ -57,6 +57,10 @@ PROVIDERS = {}
REQUIRED_PROVIDERS
=
{}
class
InvalidProvider
(
Exception
):
pass
class
AuthProviderBase
(
type
):
def
__new__
(
cls
,
name
,
bases
,
dct
):
...
...
@@ -667,6 +671,6 @@ def get_provider(module, user_obj=None, identifier=None, **params):
Return a provider instance from the auth providers registry.
"""
if
not
module
in
PROVIDERS
:
raise
Exception
(
'Invalid auth provider "%s"'
%
module
)
raise
InvalidProvider
(
'Invalid auth provider "%s"'
%
module
)
return
PROVIDERS
.
get
(
module
)(
user_obj
,
identifier
,
**
params
)
snf-astakos-app/astakos/im/views/im.py
View file @
8cccbc87
...
...
@@ -409,6 +409,12 @@ def signup(request, template_name='im/signup.html', on_success='index',
return
HttpResponseRedirect
(
reverse
(
'index'
))
provider
=
get_query
(
request
).
get
(
'provider'
,
'local'
)
try
:
auth
.
get_provider
(
provider
)
except
auth
.
InvalidProvider
,
e
:
messages
.
error
(
request
,
e
.
message
)
return
HttpResponseRedirect
(
reverse
(
"signup"
))
if
not
auth
.
get_provider
(
provider
).
get_create_policy
:
logger
.
error
(
"%s provider not available for signup"
,
provider
)
raise
PermissionDenied
...
...
@@ -591,9 +597,14 @@ def logout(request, template='registration/logged_out.html',
else
:
last_provider
=
request
.
COOKIES
.
get
(
'astakos_last_login_method'
,
'local'
)
provider
=
auth
.
get_provider
(
last_provider
)
try
:
provider
=
auth
.
get_provider
(
last_provider
)
except
auth
.
InvalidProvider
:
provider
=
auth
.
get_provider
(
'local'
)
message
=
provider
.
get_logout_success_msg
extra
=
provider
.
get_logout_success_extra_msg
if
extra
:
message
+=
"<br />"
+
extra
messages
.
success
(
request
,
message
)
...
...
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