refactoring

This commit is contained in:
wt committed 2024-05-24 16:19:44 +07:00
1 parent bff7788c70
commit 2961293a39
12 files changed
+331 -293

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
#include "auth.hpp"
// function for verify tokens
bool verify_auth(const std::string token) {
try {
// parse token
const auto decoded = jwt::decode(token);
// validate token
const auto verifier = jwt::verify()
.allow_algorithm(jwt::algorithm::hs256{JWT_SECRET_KEY})
.with_issuer("auth0");
verifier.verify(decoded);
return true;
}
catch (const std::system_error& e) {
std::cout << "Verification error: " << e.what() << std::endl;
return false;
}
catch (...) {
return false;
}
}