mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 10:51:22 +00:00
Fix inconsistent displayed name (#13645)
* Add get_json_string_field helper Introduce get_json_string_field in OrcaCloudServiceAgent.cpp to safely extract string fields from JSON objects. * Add resolve_display_name helper Introduce resolve_display_name to normalize provider metadata labels for the UI. The helper returns the first non-empty value from display_name, nickname, full_name, name, falling back to username, resolving human-facing label across varying provider payloads. * Replace safe_str anonymous function Replace get_json_string_field for better readability. * Replace resolution flow for nickname with function Consolidate both flows into one function for easier maintenance and more consistency. * Update OrcaCloudServiceAgent.hpp * Add OrcaCloudServiceAgent display name tests Add unit tests verifying OrcaCloudServiceAgent resolves a user's display name from various session JSON shapes.
This commit is contained in:
@@ -88,8 +88,8 @@ public:
|
||||
std::string access_token;
|
||||
std::string refresh_token;
|
||||
std::string user_id;
|
||||
// Orca auth semantics: user_name is unique orca cloud username(orca_xxxxx), user_nickname is
|
||||
// the display name shown in the UI when available.
|
||||
// Orca auth semantics: user_name is the unique Orca Cloud username (orca_xxxxx),
|
||||
// user_nickname is the display name shown in the UI when available.
|
||||
std::string user_name;
|
||||
std::string user_nickname;
|
||||
std::string user_avatar;
|
||||
@@ -276,13 +276,14 @@ public:
|
||||
bool refresh_now(const std::string& refresh_token, const std::string& reason, bool async = false);
|
||||
bool refresh_session_with_token(const std::string& refresh_token);
|
||||
|
||||
// Session state helpers
|
||||
// Session state helpers. nickname is the human-facing UI label after provider fallback resolution.
|
||||
bool set_user_session(const std::string& token,
|
||||
const std::string& user_id,
|
||||
const std::string& username,
|
||||
const std::string& nickname,
|
||||
const std::string& avatar,
|
||||
const std::string& refresh_token = "");
|
||||
// Accepts either nested Orca cloud / GoTrue session JSON or flat WebView token JSON.
|
||||
bool set_user_session(const nlohmann::json& session_json, bool notify_login = true);
|
||||
void clear_session();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user