1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-25 02:34:31 +01:00

implementing basic add of users

This commit is contained in:
kakwa 2015-06-15 21:30:19 +02:00
parent f79121e1e5
commit 47e51d2451
2 changed files with 27 additions and 1 deletions

View File

@ -401,6 +401,24 @@ class LdapCherry(object):
) )
raise cherrypy.HTTPRedirect("/signin") raise cherrypy.HTTPRedirect("/signin")
def _adduser(self, params):
badd = {}
for attr in self.attributes.get_attributes():
if self.attributes.attributes[attr]['type'] == 'password':
pwd1 = attr + '1'
pwd2 = attr + '2'
if params[pwd1] != params[pwd2]:
raise Exception()
params[attr] = params[pwd1]
if attr in params:
backends = self.attributes.get_backends_attributes(attr)
for b in backends:
if not b in badd:
badd[b] = {}
badd[b][backends[b]] = params[attr]
for b in badd:
self.backends[b].add_user(badd[b])
@cherrypy.expose @cherrypy.expose
def logout(self): def logout(self):
""" logout page """ logout page
@ -460,6 +478,11 @@ class LdapCherry(object):
if cherrypy.request.method.upper() == 'POST': if cherrypy.request.method.upper() == 'POST':
notification = "<script type=\"text/javascript\">$.notify('User Added')</script>" notification = "<script type=\"text/javascript\">$.notify('User Added')</script>"
cherrypy.log.error(
msg = params ,
severity = logging.DEBUG
)
self._adduser(params)
else: else:
notification = '' notification = ''

View File

@ -87,4 +87,7 @@ class Attributes:
def get_attributes(self): def get_attributes(self):
"""get the list of groups from roles""" """get the list of groups from roles"""
return self.self_attributes return self.attributes.keys()
def get_backends_attributes(self, attribute):
return self.attributes[attribute]['backends']