Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/renderer/context/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
removeAccount,
} from '../utils/auth/utils';
import {
decryptValue,
encryptValue,
setAutoLaunch,
setKeyboardShortcut,
Expand Down Expand Up @@ -149,6 +150,30 @@
return Promise.all(auth.accounts.map(refreshAccount));
}, [auth.accounts]);

const migrateAuthTokens = useCallback(async () => {
let tokensMigrated = false;

for (const account of auth.accounts) {
/**
* Check if the account is using an encrypted token.
* If not encrypt it and save it.
*/
try {
await decryptValue(account.token);
} catch (_err) {

Check warning on line 163 in src/renderer/context/App.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

The catch parameter `_err` should be named `error_`.

See more on https://sonarcloud.io/project/issues?id=gitify-app_gitify&issues=AZq3MKK3l67voGeiomd5&open=AZq3MKK3l67voGeiomd5&pullRequest=2421
const encryptedToken = await encryptValue(account.token);
account.token = encryptedToken as Token;

tokensMigrated = true;
}

Check warning on line 168 in src/renderer/context/App.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Handle this exception or don't catch it at all.

See more on https://sonarcloud.io/project/issues?id=gitify-app_gitify&issues=AZq3MKK3l67voGeiomd4&open=AZq3MKK3l67voGeiomd4&pullRequest=2421
}

if (tokensMigrated) {
setAuth(auth);

Check warning on line 172 in src/renderer/context/App.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Change the argument of this setter to not use its matching state variable

See more on https://sonarcloud.io/project/issues?id=gitify-app_gitify&issues=AZq3MKK3l67voGeiomd6&open=AZq3MKK3l67voGeiomd6&pullRequest=2421
saveState({ auth, settings });
}
}, [auth, settings]);

// biome-ignore lint/correctness/useExhaustiveDependencies: Fetch new notifications when account count or filters change
useEffect(() => {
fetchNotifications({ auth, settings });
Expand Down Expand Up @@ -178,6 +203,8 @@

// biome-ignore lint/correctness/useExhaustiveDependencies: Refresh account details on startup
useEffect(() => {
migrateAuthTokens();

refreshAllAccounts();
}, []);

Expand Down