Token verification

This commit is contained in:
KimLS
2014-08-18 20:27:15 -07:00
parent a602640188
commit ca86763c2b
6 changed files with 59 additions and 8 deletions
+32
View File
@@ -2179,3 +2179,35 @@ void SharedDatabase::SetBotInspectMessage(uint32 botid, const InspectMessage_Str
safe_delete_array(query);
}
bool SharedDatabase::VerifyToken(std::string token, int& status) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
bool res = false;
status = 0;
if(token.length() > 64) {
token = token.substr(0, 64);
}
token = EscapeString(token);
if (RunQuery(query, MakeAnyLenString(&query, "SELECT status FROM tokens WHERE token='%s'", token.c_str()), errbuf, &result)) {
safe_delete_array(query);
row = mysql_fetch_row(result);
if(row) {
status = atoi(row[0]);
res = true;
}
mysql_free_result(result);
}
else {
std::cerr << "Error in SharedDatabase::VerifyToken query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
}
return res;
}
+3
View File
@@ -75,6 +75,9 @@ public:
ItemInst* CreateItem(const Item_Struct* item, int16 charges=0, uint32 aug1=0, uint32 aug2=0, uint32 aug3=0, uint32 aug4=0, uint32 aug5=0);
ItemInst* CreateBaseItem(const Item_Struct* item, int16 charges=0);
// Web Token Verification
bool VerifyToken(std::string token, int& status);
/*
* Shared Memory crap
*/