refactor and review

This commit is contained in:
wt committed 2024-06-05 23:21:14 +07:00
1 parent 29df9728e2
commit d70d589294
6 files changed
+7 -43

No files matched your search

+1 -7
View File
@@ -23,13 +23,7 @@ void get_all_users(const httplib::Request &request, httplib::Response &response)
return;
}
jwt::decoded_jwt<jwt::traits::kazuho_picojson> decoded_token = jwt::decode(json_body["token"]);
std::string userid;
for (std::pair<const std::string, picojson::value> &e: decoded_token.get_payload_json()) {
if (e.first == "userId") {
userid = e.second.to_str();
break;
}
}
std::string userid = decoded_token.get_payload_json()["userId"].to_str();
if (userid.empty()) {
response.set_content(STRING403, JSON_TYPE);
return;