diff options
Diffstat (limited to '')
| -rw-r--r-- | src/web_service/web_backend.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/web_service/web_backend.cpp b/src/web_service/web_backend.cpp index 3a3f44dc2..5df4df5eb 100644 --- a/src/web_service/web_backend.cpp +++ b/src/web_service/web_backend.cpp | |||
| @@ -24,6 +24,7 @@ Client::JWTCache Client::jwt_cache{}; | |||
| 24 | 24 | ||
| 25 | Client::Client(const std::string& host, const std::string& username, const std::string& token) | 25 | Client::Client(const std::string& host, const std::string& username, const std::string& token) |
| 26 | : host(host), username(username), token(token) { | 26 | : host(host), username(username), token(token) { |
| 27 | std::lock_guard<std::mutex> lock(jwt_cache.mutex); | ||
| 27 | if (username == jwt_cache.username && token == jwt_cache.token) { | 28 | if (username == jwt_cache.username && token == jwt_cache.token) { |
| 28 | jwt = jwt_cache.jwt; | 29 | jwt = jwt_cache.jwt; |
| 29 | } | 30 | } |
| @@ -116,6 +117,7 @@ void Client::UpdateJWT() { | |||
| 116 | if (result.result_code != Common::WebResult::Code::Success) { | 117 | if (result.result_code != Common::WebResult::Code::Success) { |
| 117 | LOG_ERROR(WebService, "UpdateJWT failed"); | 118 | LOG_ERROR(WebService, "UpdateJWT failed"); |
| 118 | } else { | 119 | } else { |
| 120 | std::lock_guard<std::mutex> lock(jwt_cache.mutex); | ||
| 119 | jwt_cache.username = username; | 121 | jwt_cache.username = username; |
| 120 | jwt_cache.token = token; | 122 | jwt_cache.token = token; |
| 121 | jwt_cache.jwt = jwt = result.returned_data; | 123 | jwt_cache.jwt = jwt = result.returned_data; |