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
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()