Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 2 additions & 6 deletions packages/insomnia/src/account/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ export async function absorbKey(sessionId: string, key: string) {
getUserProfile({ sessionId: sessionIdResolved }),
getEncryptionKeys({ sessionId: sessionIdResolved }),
]);
const {
public_key: publicKey,
enc_private_key: encPrivateKey,
enc_symmetric_key: encSymmetricKey,
} = keys;
const { public_key: publicKey, enc_private_key: encPrivateKey, enc_symmetric_key: encSymmetricKey } = keys;
const { email, id: accountId, first_name: firstName, last_name: lastName } = profile;
const symmetricKeyStr = crypt.decryptAES(key, JSON.parse(encSymmetricKey));

Expand Down Expand Up @@ -224,7 +220,7 @@ async function _removeAllCredentials() {
* each model instance individually to clear them all out.
*
*/
async function _removeGitRepository(repo: GitRepository) {
export async function _removeGitRepository(repo: GitRepository) {
const queryIds = models.project.getQueryableGitRepositoryIds(repo._id);
const projects = await database.find<Project>(models.project.type, { gitRepositoryId: { $in: queryIds } });
Comment on lines +223 to 225
for (const p of projects) {
Expand Down
3 changes: 2 additions & 1 deletion packages/insomnia/src/routes/git-credentials.$id.delete.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { href } from 'react-router';

import { _removeGitRepository } from '~/account/session';
import { services } from '~/insomnia-data';
import { invariant } from '~/utils/invariant';
import { createFetcherSubmitHook } from '~/utils/router';
Expand All @@ -15,7 +16,7 @@ export async function clientAction({ params }: Route.ClientActionArgs) {
const connectedRepositories = await services.gitRepository.getAllByCredentialId(id);

for (const repo of connectedRepositories) {
await services.gitRepository.update(repo, { credentialsId: null });
await _removeGitRepository(repo);
}
Comment on lines 16 to 20

await services.gitCredentials.remove(credential);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Organization } from 'insomnia-api';
import { href } from 'react-router';

import { services } from '~/insomnia-data';
import { models, services } from '~/insomnia-data';
import { createFetcherLoadHook } from '~/utils/router';

import type { Route } from './+types/git-credentials.$id.related-projects';
Expand All @@ -14,8 +15,17 @@ export async function clientLoader({ params }: Route.ClientLoaderArgs) {

const relatedProjects = await services.project.getAllByGitRepositoryIds(gitRepositoryIds);

const { accountId } = await services.userSession.getOrCreate();
const organizations = JSON.parse(localStorage.getItem(`${accountId}:organizations`) || '[]') as Organization[];
const currentUserOrganizationIds = new Set([
...organizations.map(o => o.id),
models.organization.SCRATCHPAD_ORGANIZATION_ID,
]);

const currentUserProjects = relatedProjects.filter(p => currentUserOrganizationIds.has(p.parentId));

Comment on lines +18 to +26
return {
projects: relatedProjects,
projects: currentUserProjects,
};
}

Expand Down
Loading