user kann ab jetzt sein password ändern
This commit is contained in:
parent
c957195ffb
commit
2803831784
|
@ -1,3 +1,5 @@
|
||||||
|
from ldap3.core.exceptions import LDAPPasswordIsMandatoryError, LDAPBindError
|
||||||
|
|
||||||
from geruecht.exceptions import UsernameExistLDAP, LDAPExcetpion, PermissionDenied
|
from geruecht.exceptions import UsernameExistLDAP, LDAPExcetpion, PermissionDenied
|
||||||
import geruecht.controller.databaseController as dc
|
import geruecht.controller.databaseController as dc
|
||||||
import geruecht.controller.ldapController as lc
|
import geruecht.controller.ldapController as lc
|
||||||
|
@ -114,10 +116,13 @@ class Base:
|
||||||
debug.debug("user is {{ {} }}".format(user))
|
debug.debug("user is {{ {} }}".format(user))
|
||||||
return user
|
return user
|
||||||
|
|
||||||
def modifyUser(self, user, ldap_conn, attributes):
|
def modifyUser(self, user, attributes, password):
|
||||||
debug.info("modify user {{ {} }} with attributes {{ {} }} with ldap_conn {{ {} }}".format(
|
debug.info("modify user {{ {} }} with attributes {{ {} }}".format(
|
||||||
user, attributes, ldap_conn))
|
user, attributes))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
ldap_conn = ldap.bind(user, password)
|
||||||
|
if attributes:
|
||||||
if 'username' in attributes:
|
if 'username' in attributes:
|
||||||
debug.debug("change username, so change first in database")
|
debug.debug("change username, so change first in database")
|
||||||
db.changeUsername(user, attributes['username'])
|
db.changeUsername(user, attributes['username'])
|
||||||
|
@ -130,6 +135,8 @@ class Base:
|
||||||
retVal = self.getUser(user.uid)
|
retVal = self.getUser(user.uid)
|
||||||
debug.debug("user is {{ {} }}".format(retVal))
|
debug.debug("user is {{ {} }}".format(retVal))
|
||||||
return retVal
|
return retVal
|
||||||
|
return self.getUser(user.uid)
|
||||||
|
|
||||||
except UsernameExistLDAP as err:
|
except UsernameExistLDAP as err:
|
||||||
debug.debug(
|
debug.debug(
|
||||||
"username exists on ldap, rechange username on database", exc_info=True)
|
"username exists on ldap, rechange username on database", exc_info=True)
|
||||||
|
@ -139,6 +146,10 @@ class Base:
|
||||||
if 'username' in attributes:
|
if 'username' in attributes:
|
||||||
db.changeUsername(user, user.uid)
|
db.changeUsername(user, user.uid)
|
||||||
raise Exception(err)
|
raise Exception(err)
|
||||||
|
except LDAPPasswordIsMandatoryError as err:
|
||||||
|
raise Exception('Password wurde nicht gesetzt!!')
|
||||||
|
except LDAPBindError as err:
|
||||||
|
raise Exception('Password ist falsch')
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
raise Exception(err)
|
raise Exception(err)
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,10 @@ def _saveConfig(**kwargs):
|
||||||
if 'accToken' in kwargs:
|
if 'accToken' in kwargs:
|
||||||
accToken = kwargs['accToken']
|
accToken = kwargs['accToken']
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
|
password = data['acceptedPassword']
|
||||||
|
data.pop('acceptedPassword')
|
||||||
accToken.user = mainController.modifyUser(
|
accToken.user = mainController.modifyUser(
|
||||||
accToken.user, accToken.ldap_conn, data)
|
accToken.user, data, password)
|
||||||
retVal = accToken.user.toJSON()
|
retVal = accToken.user.toJSON()
|
||||||
retVal['creditList'] = {credit.year: credit.toJSON()
|
retVal['creditList'] = {credit.year: credit.toJSON()
|
||||||
for credit in accToken.user.geruechte}
|
for credit in accToken.user.geruechte}
|
||||||
|
|
Loading…
Reference in New Issue