oauth2: handle errors during password update

There is no guarantee that the password can be updated. Allow the attempt
to fail without treating it as an error (that would be confusing in the most
common case, where "password" was given on the command line) and instead
just print an INFO message with the new token and some instructions.
This commit is contained in:
Patrick Ohly 2014-09-08 20:36:44 +02:00
parent 64fb7212cf
commit be846f8e60
1 changed files with 7 additions and 2 deletions

View File

@ -107,9 +107,14 @@ public:
}
if (strcmp("refresh_token", key) == 0) {
std::string newRefreshToken = json_object_get_string(val);
SE_LOG_INFO(NULL, "refresh token invalidated - updating refresh token to %s", newRefreshToken.c_str());
if (passwordUpdateCallback) {
passwordUpdateCallback(newRefreshToken);
try {
passwordUpdateCallback(newRefreshToken);
} catch (...) {
std::string explanation;
Exception::handle(explanation, HANDLE_EXCEPTION_NO_ERROR);
SE_LOG_INFO(NULL, "The attempt to update the refresh token in the 'password' property failed, probably because there is no configuration for it: %s\nRemember to use the new token in the future: %s", explanation.c_str(), newRefreshToken.c_str());
}
}
}
}