예제 #1
0
    def put(self,userId):
        if self.userLoginCheck() != error.ERR_CODE_OK_:
            return
        if self.privilegeCheck(master='user',masterId=self.current_user,\
                              object='user',objectId=userId,operation='upd') != error.ERR_CODE_OK_:
            return
        responseApi = copy.deepcopy(restDef.RESTFUL_API[restDef.HTTP_RES['userOne']]['@PUT']['RESP'])
        requestApi = copy.deepcopy(restDef.RESTFUL_API[restDef.HTTP_RES['userOne']]['@PUT']['REQUEST'])
        self._getAllArguments(requestApi)
        #print requestApi
        #we must check oldpwd, while change the pwd
        if requestApi['pwd'] is not None:
            if requestApi['oldpwd'] is None:
                self.send_error_msg(self.__ERRCODE__['pwdwrong'])
                return
            else:
                if authManager.userAuthByIdPwd(userId,requestApi['oldpwd']) != error.ERR_CODE_OK_:
                    self.send_error_msg(self.__ERRCODE__['pwdwrong'])
                    return

        if database.db_update_user(userId, requestApi['pwd'], requestApi['userDefArea']) != error.ERR_CODE_OK_:
            self.send_error_msg(self.__ERRCODE__['innererr'])
            return
        else:
            self.write(escape.json_encode(responseApi))
예제 #2
0
def userChangeStatus(userId,state):
    if userId is None:
        return error.ERR_CODE_ERR_
    return database.db_update_user(userId,state=state)