Fix error returned from login plugins
[cascardo/ipsilon.git] / ipsilon / login / authldap.py
index 0a5bd3b..f383003 100644 (file)
@@ -1,6 +1,7 @@
 # Copyright (C) 2014  Ipsilon Contributors, see COPYING for license
 
-from ipsilon.login.common import LoginFormBase, LoginManagerBase
+from ipsilon.login.common import LoginFormBase, LoginManagerBase, \
+    LoginManagerInstaller
 from ipsilon.util.plugin import PluginObject
 from ipsilon.util.log import Log
 from ipsilon.util import config as pconfig
@@ -62,15 +63,7 @@ class LDAP(LoginFormBase, Log):
 
         if username and password:
             try:
-                userdata = self._authenticate(username, password)
-                if userdata:
-                    userattrs = dict()
-                    for d, v in userdata.get('userdata', {}).items():
-                        userattrs[d] = v
-                    if 'groups' in userdata:
-                        userattrs['groups'] = userdata['groups']
-                    if 'extras' in userdata:
-                        userattrs['extras'] = userdata['extras']
+                userattrs = self._authenticate(username, password)
                 authed = True
             except Exception, e:  # pylint: disable=broad-except
                 errmsg = "Authentication failed"
@@ -89,6 +82,7 @@ class LDAP(LoginFormBase, Log):
             error_password=not password,
             error_username=not username
         )
+        self.lm.set_auth_error()
         # pylint: disable=star-args
         return self._template('login/form.html', **context)
 
@@ -171,16 +165,16 @@ authentication. """
         return self.page
 
 
-class Installer(object):
+class Installer(LoginManagerInstaller):
 
     def __init__(self, *pargs):
+        super(Installer, self).__init__()
         self.name = 'ldap'
-        self.ptype = 'login'
         self.pargs = pargs
 
     def install_args(self, group):
         group.add_argument('--ldap', choices=['yes', 'no'], default='no',
-                           help='Configure PAM authentication')
+                           help='Configure LDAP authentication')
         group.add_argument('--ldap-server-url', action='store',
                            help='LDAP Server Url')
         group.add_argument('--ldap-bind-dn-template', action='store',