예제 #1
0
파일: account.py 프로젝트: maqg/wcrobot
def change_password(db, arg):

    user = getUser(db, userId=arg["paras"].get("id"))
    if (not user):
        ERROR("user %s not exist" % (arg["paras"].get("id")))
        return USER_NOT_EXIST

    return user.changePassword(b64_decode(arg["paras"].get('oldPassword')),
                               b64_decode(arg["paras"].get('newPassword')))
예제 #2
0
def change_password(db, arg):
    paras = arg["paras"]

    user = getAccount(db, userId=paras["id"])
    if (not user):
        ERROR("user %s not exist" % (paras["id"]))
        return USER_NOT_EXIST

    return user.changePassword(b64_decode(paras["oldPassword"]),
                               b64_decode(paras["newPassword"]))
예제 #3
0
def add_user(db, arg):
    paras = arg["paras"]

    account = paras["account"]

    user = getAccount(db, userName=account)
    if (user):
        WARNING("user %s already exist" % account)
        return USER_ALREADY_EXIST

    user = Account(db)

    user.name = account
    user.password = b64_decode(paras["password"])

    if (not user.name or not user.password):
        ERROR("not username or password specified")
        return NOT_ENOUGH_PARAS

    user.email = paras["email"]
    user.phone = paras["phoneNumber"]

    ret = user.add()

    return ret
예제 #4
0
파일: account.py 프로젝트: maqg/wcrobot
def reset_password(db, arg):
    user = getUser(db, userId=arg["paras"].get("id"))
    if (not user):
        ERROR("user %s not exist" % (arg["paras"].get("id")))
        return USER_NOT_EXIST

    return user.resetPassword(b64_decode(arg["paras"].get("password")))
예제 #5
0
def reset_password(db, arg):
    paras = arg["paras"]

    user = getAccount(db, userId=paras["id"])
    if (not user):
        ERROR("user %s not exist" % (paras["id"]))
        return USER_NOT_EXIST

    return user.resetPassword(b64_decode(paras["password"]))
예제 #6
0
파일: account_web.py 프로젝트: maqg/wcrobot
def web_login(db, env, arg):
    paras = arg["paras"]
    user = userService.getUserByName(db, paras.get("account"))
    if (not user):
        return buildRetObj(USER_NOT_EXIST, None)

    ret = user.auth(b64_decode(paras.get("password")))
    if ret == 0:
        data = {"id": user.myId, "name": user.name, "role": user.role}
        sessionObj = newSession(db, data)
        data["session"] = sessionObj
        return buildRetObj(OCT_SUCCESS, data)
    else:
        return buildRetObj(USER_PASSWD_ERR)
예제 #7
0
파일: account.py 프로젝트: maqg/wcrobot
def add_user(db, arg):

    user = getUser(db, userName=arg["paras"].get("account"))
    if (user):
        WARNING("user %s already exist" % arg["paras"].get("account"))
        return USER_ALREADY_EXIST

    user = Account(db)

    user.name = arg["paras"].get("account")
    user.password = b64_decode(arg["paras"].get("password"))

    if (not user.name or not user.password):
        ERROR("not username or password specified")
        return NOT_ENOUGH_PARAS

    user.ukey = arg["paras"].get("ukey")
    user.email = arg["paras"].get("email") or ""
    user.phone = arg["paras"].get("phoneNumber") or ""

    return user.add()