Commit 3e5a4a8a authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Configurable login method one per user limit

parent 0902a826
......@@ -100,6 +100,11 @@ class AuthProvider(object):
if override:
setattr(self, tpl_name, override)
for key in ['one_per_user']:
override = self.get_setting(key)
if override != None:
setattr(self, key, override)
def __getattr__(self, key):
if not key.startswith('get_'):
return super(AuthProvider, self).__getattribute__(key)
......@@ -118,6 +123,7 @@ class AuthProvider(object):
attr_sec = 'ASTAKOS_%s_%s' % (self.module.upper(), name.upper())
if not hasattr(settings, attr):
return getattr(settings, attr_sec, default)
return getattr(settings, attr, default)
def is_available_for_login(self):
......
......@@ -159,6 +159,7 @@ def authenticated(
user = request.user
if not request.user.can_add_auth_provider('google',
identifier=userid):
# TODO: handle existing uuid message separately
messages.error(request, _(astakos_messages.AUTH_PROVIDER_ADD_FAILED) +
u' ' + _(astakos_messages.AUTH_PROVIDER_ADD_EXISTS))
return HttpResponseRedirect(reverse('edit_profile'))
......
......@@ -152,6 +152,7 @@ def authenticated(
user = request.user
if not request.user.can_add_auth_provider('linkedin',
identifier=userid):
# TODO: handle existing uuid message separately
messages.error(request, _(astakos_messages.AUTH_PROVIDER_ADD_FAILED) +
u' ' + _(astakos_messages.AUTH_PROVIDER_ADD_EXISTS))
return HttpResponseRedirect(reverse('edit_profile'))
......
......@@ -126,6 +126,7 @@ def login(
user = request.user
if not request.user.can_add_auth_provider('shibboleth',
identifier=eppn):
# TODO: handle existing uuid message separately
messages.error(request, _(astakos_messages.AUTH_PROVIDER_ADD_FAILED) +
u' ' + _(astakos_messages.AUTH_PROVIDER_ADD_EXISTS))
return HttpResponseRedirect(reverse('edit_profile'))
......
......@@ -145,6 +145,7 @@ def authenticated(
user = request.user
if not request.user.can_add_auth_provider('twitter',
identifier=userid):
# TODO: handle existing uuid message separately
messages.error(request, _(astakos_messages.AUTH_PROVIDER_ADD_FAILED) +
u' ' + _(astakos_messages.AUTH_PROVIDER_ADD_EXISTS))
return HttpResponseRedirect(reverse('edit_profile'))
......
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