Fix Snapmaker account login not persisting across restarts - #715
Open
amitamit10 wants to merge 1 commit into
Open
Fix Snapmaker account login not persisting across restarts#715amitamit10 wants to merge 1 commit into
amitamit10 wants to merge 1 commit into
Conversation
The native SMUserInfo struct (m_login_userinfo) that backs sw_GetUserLoginState was only ever populated in-memory during an active login flow (WebSMUserLoginDialog::OnNavigationRequest) and was never written to or restored from AppConfig. Every app restart therefore started with an empty, logged-out struct regardless of whether the embedded webview still had a valid cached token, so the Snapmaker login screen reappeared on every launch. This persists the token/account/nickname/icon/id to a new "sm_user" AppConfig section on successful login, restores it into m_login_userinfo right after AppConfig::load() during startup (before the webview's first sw_GetUserLoginState call), and clears the persisted section on logout so a revoked token isn't restored. Fixes Snapmaker#669
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #669 (and the same underlying cause behind the related reports in #226, #116, and #716).
The native
SMUserInfostruct (m_login_userinfo), which backssw_GetUserLoginStatefor the embedded Flutter login webview, was only ever populated in-memory during an active login flow (WebSMUserLoginDialog::OnNavigationRequest) and was never written to or restored fromAppConfig. Every app restart therefore started with an empty, logged-out struct — regardless of whether the embedded webview's ownlocalStoragestill had a cached token — so the login screen reappeared on every launch even though the account token itself was still valid.This was reproducible outside the Flatpak sandbox too (confirmed on a from-source Linux build), which rules out sandbox/permission causes such as keyring access or the webview's local-server port.
Platform scope
All existing reports of this symptom are Linux-only, but the affected code (
WebSMUserLoginDialog::OnNavigationRequest,GUI_App::sm_get_login_info, theSMUserInfostruct) has no#ifdef _WIN32/__APPLE__guards anywhere — it's plain cross-platform C++ shared by every build. The native "am I logged in" check always reads fromm_login_userinfo, which resets to its default (logged-out) state on every process launch regardless of OS or webview backend (WebKitGTK/WebView2/WKWebView). I don't have a Windows or macOS machine to confirm directly, but nothing in the code path is platform-specific, so this likely affects those builds too, just underreported so far.Fix
WebSMUserLoginDialog.cpp), persist token/account/nickname/icon/id to a newsm_userAppConfigsection and save immediately.GUI_App.cpp), right afterAppConfig::load()and before the webview's firstsw_GetUserLoginStatecall, restore the saved session intom_login_userinfoif a token is present.sm_request_user_logout), clear the persistedsm_user.tokenso a revoked session isn't restored on next launch.Test plan
sm_usersection written toAppConfig(~/.config/Snapmaker_Orca/Snapmaker_Orca.conf) with token/account/nickname/icon/id