Skip to content

fix(windows): keep user data local, log errors - #271

Open
edospadoni wants to merge 2 commits into
mainfrom
fix/windows-local-userdata
Open

edospadoni wants to merge 2 commits into
mainfrom
fix/windows-local-userdata

Conversation

@edospadoni

@edospadoni edospadoni commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Some users run NethLink with the same account on two Windows PCs, such as an office PC and a notebook for remote work, and NethLink keeps asking them for the password. On Windows NethLink stored its data in the roaming profile folder (%APPDATA%), which companies often redirect or sync between PCs. The saved password is encrypted with Electron safeStorage, which on Windows uses DPAPI (the Windows data protection API), tied to the machine and the Windows user: a password saved on one PC may not decrypt on the other, and the two PCs overwrite each other's settings. We could not confirm the cause from the customer's logs, because in production NethLink wrote almost nothing to its log file.

On Windows the data now lives in the local, per-machine folder (%LOCALAPPDATA%). On the first start NethLink copies its settings and the saved audio devices and ringtone from the old folder, which stays in place for older versions. On every platform, warnings and errors now reach the log file in production too.

  • src/main/lib/localUserData.ts: moves the data folder on Windows before anything reads it, so it is the first import in main.ts
  • src/shared/utils/logger.ts: writes warnings and errors in production, keeps error messages instead of {}, and fixes main process messages that never reached the file
  • AccountController.autoLogin(): logs a dedicated warning when the saved password cannot be decrypted

How to test

  • On Windows, install the testing build over an existing installation: NethLink starts already signed in, with the same audio devices and ringtone, and the data is now in %LOCALAPPDATA%\nethlink
  • On a PC whose roaming folder is shared with another PC, sign in on both: after a restart each PC signs in on its own without asking for the password
  • Without DEV=true, corrupt lastUserCryptPsw in user_data.json while NethLink is closed, then start it: the login page appears and the log file in logs\ contains cannot decrypt the saved password with safeStorage

The roaming folder can be redirected or synced between the PCs of the
same user, such as the office PC and the smart working notebook. The
password is encrypted with safeStorage, that is DPAPI bound to the
machine, so a blob written on one PC may not decrypt on the other and
NethLink asks for the password again. The PCs also overwrite each
other's state.

On the first start the app copies its state and the renderer
localStorage (audio devices, ringtone) from the old roaming folder,
which is left in place for older versions.

Assisted-by: Claude Code:claude-opus-5-5
In production nothing but the PhoneIsland lines reached the log file,
so a failed auto login on a customer's PC left no trace. Warnings and
errors are now always written, info and debug stay dev only.

The main process messages were also lost in dev: ipcMain.emit passed
the message where the listener expects the event. Errors are logged
with name and message instead of {}, and a password that safeStorage
cannot decrypt gets its own warning.

Assisted-by: Claude Code:claude-opus-5-5
@edospadoni edospadoni self-assigned this Nov 23, 2026
@github-actions

Copy link
Copy Markdown

Automatic builds from https://github.com/NethServer/nethlink/actions/runs/45152043348.
Commit: ec9694a

Name Platform Link
win-app.exe Windows (x64) Link
macos-app-x64.dmg MacOS (x64) Link
macos-app-arm64.dmg MacOS (arm64) Link
linux-app.AppImage Linux (x64) Link

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant