当前位置: 首页>>代码示例>>C++>>正文


C++ UserSession::isAdmin方法代码示例

本文整理汇总了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;
	}	
};
开发者ID:ctfight,项目名称:jury,代码行数:29,代码来源:games_insert.cpp

示例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;
	}
};
开发者ID:ctfight,项目名称:jury,代码行数:10,代码来源:admin_userupdate.cpp

示例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;
	}
};
开发者ID:ctfight,项目名称:jury,代码行数:37,代码来源:games_delete.cpp


注:本文中的UserSession::isAdmin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。