本文整理汇总了C++中UserSession::isAdmin方法的典型用法代码示例。如果您正苦于以下问题:C++ UserSession::isAdmin方法的具体用法?C++ UserSession::isAdmin怎么用?C++ UserSession::isAdmin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserSession
的用法示例。
在下文中一共展示了UserSession::isAdmin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleRequest
void GamesInsert::handleRequest(GlobalContext *pGlobalContext, QSqlDatabase *db, QHttpRequest *req, QJsonObject &response) {
UserSession *pUserSession = pGlobalContext->userSession(req->url(), db);
if (pUserSession == NULL) {
setErrorResponse(response, 1021, "token are not found");
return;
} else if (!pUserSession->isAdmin()) {
setErrorResponse(response, 1022, "this method only for admin");
return;
}
QUrlQuery urlQuery(req->url());
QString name = urlQuery.queryItemValue("name");
if (name.isEmpty()) {
setErrorResponse(response, 1055, "Parameter name are not found or it is empty");
return;
}
QSqlQuery query(*db);
query.prepare("INSERT INTO backend_games(name) VALUES(:name)");
query.bindValue(":name", name);
if (query.exec()) {
response["result"] = QString("ok");
response["id"] = query.lastInsertId().toInt();
} else {
setErrorResponse(response, 1056, query.lastError().text());
return;
}
};
示例2: handleRequest
void AdminUserUpdate::handleRequest(GlobalContext *pGlobalContext, QSqlDatabase *db, QHttpRequest *req, QJsonObject &response) {
UserSession *pUserSession = pGlobalContext->userSession(req->url(), db);
if (pUserSession == NULL) {
setErrorResponse(response, 1074, "token are not found");
return;
} else if (!pUserSession->isAdmin()) {
setErrorResponse(response, 1075, "this method only for admin");
return;
}
};
示例3: handleRequest
void GamesDelete::handleRequest(GlobalContext *pGlobalContext, QSqlDatabase *db, QHttpRequest *req, QJsonObject &response) {
UserSession *pUserSession = pGlobalContext->userSession(req->url(), db);
if (pUserSession == NULL) {
setErrorResponse(response, 1025, "token are not found");
return;
} else if (!pUserSession->isAdmin()) {
setErrorResponse(response, 1026, "this method only for admin");
return;
}
QUrlQuery urlQuery(req->url());
QString sId = urlQuery.queryItemValue("id");
if (sId.isEmpty()) {
setErrorResponse(response, 1057, "Parameter id are not found or it is empty");
return;
}
bool bConvert;
int nId = sId.toInt(&bConvert, 10);
if (!bConvert) {
setErrorResponse(response, 1058, "Parameter id must be integer");
return;
}
// TODO check exists game
QSqlQuery query(*db);
query.prepare("DELETE FROM backend_games WHERE id = :id");
query.bindValue(":id", nId);
if (query.exec()) {
response["result"] = QString("ok");
} else {
setErrorResponse(response, 1059, query.lastError().text());
return;
}
};