diff --git a/wrenchboard/src/shared_tool/account.cc b/wrenchboard/src/shared_tool/account.cc index 520b2c66..c45ed3ed 100644 --- a/wrenchboard/src/shared_tool/account.cc +++ b/wrenchboard/src/shared_tool/account.cc @@ -442,17 +442,24 @@ long account_calls(CVars in, CVars &out) { long VerifyWrenchAccountLink(CVars in, CVars &out) { logfmt(logINFO, "VerifyWrenchAccountLink()"); long ret = PHP_API_BAD_PARAM; + const PGresult *res; REQ_STRING(in, "verify_link", 2, 120, "(.*)"); OPTIONAL(in, "loc") REQ_STRING(in, "loc", 3, 15, "(.*)"); out["status_text"] = "Start"; out["status"] = "-1"; try { - long lonkF = load_db_record(out, "SELECT uid AS pending_uid,id AS pending_id FROM members_pending WHERE verify_link ='%s' AND expire > now() AND status = 1 LIMIT 1", in["verify_link"].c_str()); - if (lonkF) { - out["status_text"] = "Link Verfied"; - out["status"] = "0"; - ret = PHP_API_OK; - } + res = pgsql_query("SELECT uid AS pending_uid,id AS pending_id FROM members_pending WHERE verify_link ='%s' AND expire > now() AND status = 1 LIMIT 1",in["verify_link"].c_str()); + if (res != NULL && pgsql_num_rows(res) > 0) { + mapf = pgsql_fetch_assoc(res, 0); + CVars rec; + map_to_cvars(f, rec); + out["pending_uid"] = rec["pending_uid"]; out["pending_uid"].set_valid( true ); + out["pending_id"] = rec["pending_id"]; out["pending_id"].set_valid( true ); + out["status_text"] = "Link Verfied"; + out["status"] = "0"; + ret = PHP_API_OK; + } + } catch (bad_parameter) { out["status"] = "ERROR"; }