401
401
# Execute the query.
402
402
return self.insert(fields, "login", self.login_fields, dry=dry)
404
def update_user(self, login, dry=False, **kwargs):
405
"""Updates fields of a particular user. login is the name of the user
406
to update. The dict contains the fields which will be modified, and
407
their new values. If any value is omitted from the dict, it does not
408
get modified. login and studentid may not be modified.
409
Passhash may be modified by supplying a "password" field, in
410
cleartext, not a hashed password.
412
Note that no checking is done. It is expected this function is called
413
by a trusted source. In particular, it allows the password to be
414
changed without knowing the old password. The caller should check
415
that the user knows the existing password before calling this function
418
if 'passhash' in kwargs:
419
raise DBException("Supplied arguments include passhash (invalid) (2).")
420
if "password" in kwargs:
421
kwargs = copy.copy(kwargs)
422
kwargs['passhash'] = _passhash(kwargs['password'])
423
del kwargs['password']
424
return self.update({"login": login}, kwargs, "login",
425
self.login_fields, self.login_primary, ["login", "studentid"],
428
404
def get_user(self, login, dry=False):
429
405
"""Given a login, returns a User object containing details looked up