MCPcopy Create free account
hub / github.com/AstroPrint/AstroBox / changeUserPin

Method changeUserPin

src/astroprint/users.py:221–243  ·  view source on GitHub ↗
(self, username, pin)

Source from the content-addressed store, hash-verified

219 self._save()
220
221 def changeUserPin(self, username, pin):
222 if not username in self._users.keys():
223 raise UnknownUser(username)
224
225 if pin is not None:
226 try:
227 if len(pin) != 4 or int(pin) < 0 or int(pin) > 9999:
228 raise InvalidPinException(pin)
229 except ValueError:
230 raise InvalidPinException(pin)
231
232
233 pinHash = UserManager.createPasswordHash(pin)
234 user = self._users[username]
235 if user._pinHash != pinHash:
236 user._pinHash = pinHash
237 self._dirty = True
238 self._save()
239
240 if pin is None:
241 eventManager().fire(Events.PIN_STATUS, False)
242 else:
243 eventManager().fire(Events.PIN_STATUS, True)
244
245 def changeUserPassword(self, username, password):
246 if not username in self._users.keys():

Callers 3

loginFunction · 0.80
setPinMethod · 0.80
getSoftwarePinFunction · 0.80

Calls 6

_saveMethod · 0.95
eventManagerFunction · 0.90
UnknownUserClass · 0.85
InvalidPinExceptionClass · 0.85
createPasswordHashMethod · 0.80
fireMethod · 0.80

Tested by

no test coverage detected