Skip to content

Commit

Permalink
To handle "Internal server error 500" save and load passwordHash to u…
Browse files Browse the repository at this point in the history
…ser.yaml

passwordHash in user.yaml is updated after every successful check_password via ldap with forced save.
  • Loading branch information
BlackJaecky committed Oct 26, 2022
1 parent 5c08dfb commit a248d9a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion octoprint_auth_ldap/user_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def check_password(self, username, password):
self.logger.debug("%s was %sauthenticated" % (user.get_name(), "" if authenticated else "not "))
if authenticated:
user._passwordHash = LDAPUserManager.create_password_hash(password, settings=self._settings)
self._save(force=True)
return authenticated
else:
self.logger.debug("%s is inactive or no longer a member of required groups" % user.get_id())
Expand Down Expand Up @@ -187,6 +188,7 @@ def _load(self):
self.logger.debug("Loading %s as %s" % (name, LDAPUser.__name__))
self._users[name] = LDAPUser(
username=name,
passwordHash=attributes["password"],
active=attributes["active"],
permissions=permissions,
groups=groups,
Expand Down Expand Up @@ -234,7 +236,7 @@ def _save(self, force=False):
# password field has to exist because of how FilebasedUserManager processes
# data, but an empty password hash cannot match any entered password (as
# whatever the user enters will be hashed... even an empty password.
"password": None,
"password": user._passwordHash,

"active": user._active,
"groups": self._from_groups(*user._groups),
Expand Down

0 comments on commit a248d9a

Please sign in to comment.