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

Class User

src/astroprint/users.py:323–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321##~~ User object
322
323class User(UserMixin):
324 def __init__(self, username, passwordHash, active, roles, publicKey=None, privateKey=None, apikey=None, orgId = None, groupId = None, pinHash= None):
325 self._username = username
326 self._passwordHash = passwordHash
327 self._active = active
328 self._roles = roles
329 self._apikey = apikey
330 self._pinHash = pinHash
331
332 self.publicKey = publicKey
333 self.privateKey = privateKey
334 self.orgId = orgId
335 self.groupId = groupId
336
337 def asDict(self):
338 return {
339 "name": self._username,
340 "active": self._active,
341 "admin": self.is_admin(),
342 "user": self.is_user(),
343 "apikey": self._apikey,
344 "privateKey": self.privateKey,
345 "publicKey": self.publicKey,
346 "orgId" : self.orgId,
347 "groupId" : self.groupId
348 }
349
350 def check_password(self, passwordHash):
351 return self._passwordHash == passwordHash
352
353 def check_privateKey(self, privateKey):
354 return self.privateKey == privateKey
355
356 def check_pin(self, pin):
357 return not self.has_pin() or self._pinHash == UserManager.createPasswordHash(pin)
358
359 def has_pin(self):
360 return self._pinHash is not None
361
362 def get_id(self):
363 return self._username
364
365 def get_name(self):
366 return self._username
367
368 def has_password(self):
369 if self._passwordHash is not None:
370 return True
371
372 def get_private_key(self):
373 return self.privateKey
374
375 def is_active(self):
376 return self._active
377
378 def is_user(self):
379 return "user" in self._roles
380

Callers 2

_loadMethod · 0.85
addUserMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected