implement password change
This commit is contained in:
parent
bf5ba98ab8
commit
6446c09a01
3 changed files with 85 additions and 27 deletions
|
@ -3,8 +3,15 @@ from json import load
|
|||
from os import environ
|
||||
|
||||
from flask import redirect, session, url_for
|
||||
from ldap3 import ALL, ALL_ATTRIBUTES, MODIFY_REPLACE, Connection, Server
|
||||
from ldap3 import (
|
||||
ALL_ATTRIBUTES,
|
||||
HASHED_SALTED_SHA512,
|
||||
MODIFY_REPLACE,
|
||||
Connection,
|
||||
Server,
|
||||
)
|
||||
from ldap3.core.exceptions import LDAPException
|
||||
from ldap3.utils.hashed import hashed
|
||||
|
||||
with open(environ["APP_CONFIG"]) as f:
|
||||
APP_CONFIG = load(f)
|
||||
|
@ -112,5 +119,15 @@ def update_user(ldap, username, settings):
|
|||
)
|
||||
|
||||
|
||||
def update_user_password(ldap, username, password):
|
||||
return update_user(
|
||||
ldap,
|
||||
username,
|
||||
{
|
||||
"userPassword": hashed(HASHED_SALTED_SHA512, password),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class UserNotFoundException(Exception):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue