Project

General

Profile

« Previous | Next » 

Revision 6a622bf4

Added by Serghei Mihai about 9 years ago

fail login if ldap not available (#6827)

View differences:

uauth/templates/uauth/login_failed.html
7 7

  
8 8
{% block content %}
9 9
  <h3>{% trans "Your authentication attempt failed" %}</h3>
10
  <p>{% trans "This is probably because you tried to log against a wrong provider" %}  </p>
10
  <p>
11
  {% blocktrans %}
12
  This is probably because you tried to log against a wrong provider or an error occured during authentication
13
  {% endblocktrans %}
14
  </p>
11 15
{% endblock %}
12 16

  
uauth/utils.py
54 54
        dn = 'uid=%s,%s' % (username, settings.LDAP_CONF['dn'])
55 55
        logger.debug('creating new radius user: %s' % dn)
56 56
        connection.add_s(dn, ldif)
57
        return True
58
    else:
59
        return False
uauth/views.py
43 43
        if is_organization_idp(eduPersonTargetedID_NameQualifier, organization):
44 44
            username = uuid4().get_hex()
45 45
            password = uuid4().get_hex()
46
            create_radius_user(username, password)
47
            params = QueryDict(self.request.session[organization.slug], mutable=True)
48
            hotspot_url = organization.hotspot_url
49

  
50
            if 'login_url' in params:
51
                hotspot_url = params.pop('login_url')[0]
52

  
53
            context = {'organization': organization,
54
                       'params':  params.urlencode(),
55
                       'hotspot_url': hotspot_url,
56
                       'data': {'username': username,
57
                                'password': password
58
                        }
59
            }
60
            prefix = organization.hotspot_type
61
            return render_to_response('uauth/%s_login_successfull.html' % organization.hotspot_type,
62
                                      context)
46
            context = {'organization': organization}
47
            if create_radius_user(username, password):
48
                params = QueryDict(self.request.session[organization.slug], mutable=True)
49
                hotspot_url = organization.hotspot_url
50

  
51
                if 'login_url' in params:
52
                    hotspot_url = params.pop('login_url')[0]
53

  
54
                context.update({'params':  params.urlencode(),
55
                                'hotspot_url': hotspot_url,
56
                                'data': {'username': username,
57
                                         'password': password
58
                                     }
59
                            })
60
                return render_to_response('uauth/%s_login_successfull.html' % organization.hotspot_type,
61
                                          context)
63 62
        return render_to_response('uauth/login_failed.html', context)
64 63

  
65 64
login = csrf_exempt(LoginView.as_view())

Also available in: Unified diff