fail login if ldap not available (#6827)

This commit is contained in:
Serghei Mihai 2015-03-25 15:31:23 +01:00
parent 65c2ac7aa2
commit 6a622bf46a
3 changed files with 22 additions and 16 deletions

View File

@ -7,6 +7,10 @@
{% block content %}
<h3>{% trans "Your authentication attempt failed" %}</h3>
<p>{% trans "This is probably because you tried to log against a wrong provider" %} </p>
<p>
{% blocktrans %}
This is probably because you tried to log against a wrong provider or an error occured during authentication
{% endblocktrans %}
</p>
{% endblock %}

View File

@ -54,3 +54,6 @@ def create_radius_user(username, password, **kwargs):
dn = 'uid=%s,%s' % (username, settings.LDAP_CONF['dn'])
logger.debug('creating new radius user: %s' % dn)
connection.add_s(dn, ldif)
return True
else:
return False

View File

@ -43,23 +43,22 @@ class LoginView(MellonLoginView):
if is_organization_idp(eduPersonTargetedID_NameQualifier, organization):
username = uuid4().get_hex()
password = uuid4().get_hex()
create_radius_user(username, password)
params = QueryDict(self.request.session[organization.slug], mutable=True)
hotspot_url = organization.hotspot_url
context = {'organization': organization}
if create_radius_user(username, password):
params = QueryDict(self.request.session[organization.slug], mutable=True)
hotspot_url = organization.hotspot_url
if 'login_url' in params:
hotspot_url = params.pop('login_url')[0]
if 'login_url' in params:
hotspot_url = params.pop('login_url')[0]
context = {'organization': organization,
'params': params.urlencode(),
'hotspot_url': hotspot_url,
'data': {'username': username,
'password': password
}
}
prefix = organization.hotspot_type
return render_to_response('uauth/%s_login_successfull.html' % organization.hotspot_type,
context)
context.update({'params': params.urlencode(),
'hotspot_url': hotspot_url,
'data': {'username': username,
'password': password
}
})
return render_to_response('uauth/%s_login_successfull.html' % organization.hotspot_type,
context)
return render_to_response('uauth/login_failed.html', context)
login = csrf_exempt(LoginView.as_view())