def edit_staff_proxy( cookie, mpass, username, newpassword=None, newclass=None, originalpassword="", reign=None, disable=None ): user = staff.StaffMember.get_from_cookie(cookie) if user.username == username: if misc.hide_critical_data(originalpassword, config.SECRET) != user.password: raise WakaError(strings.WRONGPASS) newclass = None reign = None elif user.account == staff.ADMIN: edited_user = staff.StaffMember.get(username) if edited_user.account == staff.ADMIN and mpass != config.ADMIN_PASS: raise WakaError("Incorrect management password.") else: raise WakaError(strings.INSUFFICIENTPRIVILEGES) staff.edit_staff(username, clear_pass=newpassword, new_class=newclass, reign=reign, disable=disable) board = local.environ["waka.board"] forward_task = "admin" if user.username == username else "staff" return make_http_forward(misc.make_script_url(task=forward_task, board=board.name), config.ALTERNATE_REDIRECT)
def edit_staff_proxy(admin, mpass, username, newpassword=None, newclass=None, originalpassword='', reign=None, disable=None): user = staff.check_password(admin) if user.username == username: if misc.hide_critical_data(originalpassword, config.SECRET) \ != user.password: raise WakaError(strings.WRONGPASS) newclass = None reign = None elif user.account == staff.ADMIN: edited_user = staff.StaffMember.get(username) if edited_user.account == staff.ADMIN and mpass != config.ADMIN_PASS: raise WakaError('Incorrect management password.') else: raise WakaError(strings.INUSUFFICENTPRIVLEDGES) staff.edit_staff(username, clear_pass=newpassword, new_class=newclass, reign=reign, disable=disable) board = local.environ['waka.board'] forward_task = 'admin' if user.username == username else 'staff' return make_http_forward(misc.make_script_url(task=forward_task, board=board.name), config.ALTERNATE_REDIRECT)
def reset_password(username): import staff new_password = os.urandom(8).encode("base64").strip("=\n") try: staff.edit_staff(username, clear_pass=new_password) except staff.LoginError: print "No such user %r" % username else: print "Password of %r set to %r" % (username, new_password) cleanup()
def edit_staff_proxy(admin, mpass, username, newpassword=None, newclass=None, originalpassword='', reign=None, disable=None): user = staff.check_password(admin) if user.username == username: if misc.hide_critical_data(originalpassword, config.SECRET) \ != user.password: raise WakaError(strings.WRONGPASS) newclass = None reign = None elif user.account == staff.ADMIN: edited_user = staff.StaffMember.get(username) if edited_user.account == staff.ADMIN and mpass != config.ADMIN_PASS: raise WakaError('Incorrect management password.') else: raise WakaError(strings.INSUFFICIENTPRIVILEGES) staff.edit_staff(username, clear_pass=newpassword, new_class=newclass, reign=reign, disable=disable) board = local.environ['waka.board'] forward_task = 'admin' if user.username == username else 'staff' return make_http_forward( misc.make_script_url(task=forward_task, board=board.name), config.ALTERNATE_REDIRECT)