Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix login issue #9012

Merged
merged 6 commits into from
Dec 11, 2024
Merged

Fix login issue #9012

merged 6 commits into from
Dec 11, 2024

Conversation

charlesBochet
Copy link
Member

No description provided.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR addresses login issues by enhancing validation and authentication flows across the frontend and backend components.

  • Improved object metadata loading with new hooks useLoadMockedObjectMetadataItems and useRefreshObjectMetadataItems in /packages/twenty-front/src/modules/object-metadata/hooks/
  • Enhanced logo URL validation using isNonEmptyString instead of isDefined in /packages/twenty-front/src/modules/auth/components/Logo.tsx and ImageInput.tsx
  • Added token-based authentication for workspace logos in /packages/twenty-server/src/engine/core-modules/workspace/workspace.resolver.ts
  • Modified environment variable handling in vite.config.ts to use _env_ instead of process.env
  • Added validation in RecordActionMenuEntriesSetter.tsx to prevent null reference errors with object metadata

10 file(s) reviewed, 9 comment(s)
Edit PR Review Bot Settings | Greptile

import { useFindManyObjectMetadataItems } from '@/object-metadata/hooks/useFindManyObjectMetadataItems';
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
import { useLoadMockedObjectMetadataItems } from '@/object-metadata/hooks/useLoadMockedObjectMetadataItems';
import { useRefreshObjectMetadataItems } from '@/object-metadata/hooks/useRefreshObjectMetadataItem';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: typo in import path - 'useRefreshObjectMetadataItem' should be 'useRefreshObjectMetadataItems' to match the actual hook name

) {
loadMockedObjectMetadataItems();
} else {
refreshObjectMetadataItems();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: refreshObjectMetadataItems is an async function but the await is missing here

Comment on lines 49 to 51
const primaryLogoUrl = getImageAbsoluteURI(
props.primaryLogo ?? defaultPrimaryLogoUrl,
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: check if primaryLogo could also be an empty string - may need similar validation

Comment on lines +12 to +13
snapshot.getLoadable(objectMetadataItemsState).getValue(),
generatedMockObjectMetadataItems,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: getLoadable().getValue() may throw if atom is in error state. Consider using try/catch.

Comment on lines +14 to +17
const result = await client.query<ObjectMetadataItemsQuery>({
query: FIND_MANY_OBJECT_METADATA_ITEMS,
variables: {},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Missing error handling for failed GraphQL queries. Add try/catch block.

Comment on lines +14 to +17
const result = await client.query<ObjectMetadataItemsQuery>({
query: FIND_MANY_OBJECT_METADATA_ITEMS,
variables: {},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider adding fetchPolicy to prevent stale cache data during refresh


const objectMetadataItems =
mapPaginatedObjectMetadataItemsToObjectMetadataItems({
pagedObjectMetadataItems: result.data,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: result.data could be undefined here, causing runtime error

@@ -27,6 +27,7 @@ export class FileController {
@Req() req: Request,
) {
const folderPath = checkFilePath(params[0]);

const filename = checkFilename(params['filename']);

const workspaceId = (req as any)?.workspaceId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Unsafe type assertion. Consider proper typing of the Request object or middleware to ensure workspaceId exists

Comment on lines +205 to +207
} catch (e) {
workspaceLogoWithToken = workspace.logo;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider logging the error before falling back to raw logo URL

Copy link
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@charlesBochet charlesBochet merged commit 224b6d1 into main Dec 11, 2024
17 checks passed
@charlesBochet charlesBochet deleted the fix-login-issue branch December 11, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants