1
0
mirror of https://github.com/moepman/bk-dss synced 2024-11-17 19:39:11 +01:00

Fix stupid bugs (dict in format).

This commit is contained in:
Markus 2016-03-20 17:17:13 +01:00
parent 60f6671d1d
commit ae02dc4944
2 changed files with 10 additions and 9 deletions

View File

@ -16,7 +16,8 @@ CREATE_ATTRS = {
'loginShell' : '/bin/bash',
'sn' : '{sn}',
'uid' : '{user}',
'uidNumber' : '{uid}'
'uidNumber' : '{uid}',
'gidNumber' : '1000'
}
REDIS_HOST = "127.0.0.1"

View File

@ -3,6 +3,7 @@
from flask import Flask, render_template, redirect, url_for, session
from flask_wtf import Form
import ldap
import ldap.modlist
from redis import Redis
import uuid
from wtforms.fields import IntegerField, PasswordField, SelectField, StringField, SubmitField
@ -84,20 +85,19 @@ def create():
'gn' : form.gn.data,
'sn' : form.sn.data,
}
dn = app.config.get('CREATE_DN').format(d)
dn = app.config.get('CREATE_DN').format(**d)
attrs = {}
for k,v in app.config.get('CREATE_ATTRS'):
if isinstance(v, string):
attrs[k] = v.format(d)
for k,v in app.config.get('CREATE_ATTRS').iteritems():
if type(v) == str:
attrs[k] = v.format(**d)
elif isinstance(v, list):
attrs[k] = []
for e in v:
attrs[k].append(v.format(d))
attrs[k].append(e.format(**d))
l.add_s(dn, ldap.modlist.addModlist(attrs))
except:
except ldap.LDAPError as e:
l.unbind_s()
# TODO better message
return render_template('error.html', message="Something went wrong.", nav=buildNav())
return render_template('error.html', message=e.message['desc'] + ": " + e.message['info'], nav=buildNav())
else:
l.unbind_s()
return render_template('success.html', message="User successfully created.", nav=buildNav())