コード例 #1
0
ファイル: staff_interface.py プロジェクト: dequis/wakarimasen
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)
コード例 #2
0
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)
コード例 #3
0
ファイル: wakarimasen.py プロジェクト: k-anon/wakarimasen
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()
コード例 #4
0
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()
コード例 #5
0
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)