diff --git a/idp/src/account/service.ts b/idp/src/account/service.ts index 4e57847e9..68ecc9f84 100644 --- a/idp/src/account/service.ts +++ b/idp/src/account/service.ts @@ -7,7 +7,7 @@ import { hashPassword } from '@/infra/password' import search, { USER_SEARCH_INDEX } from '@/infra/search' import { User } from '@/user/model' import userRepo from '@/user/repo' -import { mapEntity, UserDTO } from '@/user/service' +import { UserDTO, mapEntity } from '@/user/service' export type AccountCreateOptions = { email: string @@ -40,8 +40,8 @@ export async function createUser( const emailConfirmationToken = newHyphenlessUuid() const user = await userRepo.insert({ id, - username: options.email, - email: options.email, + username: options.email.toLocaleLowerCase(), + email: options.email.toLocaleLowerCase(), fullName: options.fullName, picture: options.picture, passwordHash: hashPassword(options.password), diff --git a/idp/src/token/service.ts b/idp/src/token/service.ts index 12d0a037c..9706829cd 100644 --- a/idp/src/token/service.ts +++ b/idp/src/token/service.ts @@ -30,7 +30,7 @@ export async function exchange(options: TokenExchangeOptions): Promise { if (options.grant_type === 'password') { let user: User try { - user = await userRepo.findByUsername(options.username) + user = await userRepo.findByUsername(options.username.toLocaleLowerCase()) } catch { throw newError({ code: ErrorCode.InvalidUsernameOrPassword }) } diff --git a/ui/src/components/file/file-menu.tsx b/ui/src/components/file/file-menu.tsx index 0fc9dfcef..f2db2f90a 100644 --- a/ui/src/components/file/file-menu.tsx +++ b/ui/src/components/file/file-menu.tsx @@ -1,12 +1,12 @@ import { ChangeEvent, MouseEvent, useCallback, useMemo, useRef } from 'react' import { - Button, IconButton, Menu, MenuButton, MenuDivider, MenuItem, MenuList, + MenuOptionGroup, Portal, } from '@chakra-ui/react' import cx from 'classnames' @@ -18,19 +18,19 @@ import { } from '@/client/api/permission' import { swrConfig } from '@/client/options' import { - IconFileCopy, + IconArrowTopRight, + IconCheckBoxOutlineBlank, + IconDelete, IconDownload, IconEdit, - IconArrowTopRight, + IconFileCopy, IconGroup, - IconDelete, - IconUpload, IconHistory, IconModeHeat, + IconMoreVert, IconSecurity, IconSelectCheckBox, - IconCheckBoxOutlineBlank, - IconMoreVert, + IconUpload, } from '@/lib/components/icons' import downloadFile from '@/lib/helpers/download-file' import { @@ -162,15 +162,23 @@ const FileMenu = ({ () => file !== undefined && geEditorPermission(file.permission), [file], ) - const isAnyFeatureAuthorized = useMemo( - () => - isInsightsAuthorized || + const isProToolsAvailable = useMemo( + () => isInsightsAuthorized || isMosaicAuthorized || isWatermarkAuthorized, + [isInsightsAuthorized, isMosaicAuthorized, isWatermarkAuthorized], + ) + const isManagementAvailable = useMemo(() => { + return ( isSharingAuthorized || isSnapshotsAuthorized || - isMosaicAuthorized || - isWatermarkAuthorized, - [], - ) + isUploadAuthorized || + isDownloadAuthorized + ) + }, [ + isSharingAuthorized, + isSnapshotsAuthorized, + isUploadAuthorized, + isDownloadAuthorized, + ]) const uploadInputRef = useRef(null) const handleUploadInputChange = useCallback( @@ -202,50 +210,6 @@ const FileMenu = ({ return ( <> - {isToolbarMode ? ( - <> - {isInsightsAuthorized ? ( - - ) : null} - {isSharingAuthorized ? ( - - ) : null} - {isSnapshotsAuthorized ? ( - - ) : null} - {isMosaicAuthorized ? ( - - ) : null} - {isWatermarkAuthorized ? ( - - ) : null} - - ) : null} {isToolbarMode ? ( - {!isToolbarMode && isInsightsAuthorized ? ( - <> - } - onClick={(event: MouseEvent) => { - event.stopPropagation() - dispatch(insightsModalDidOpen()) - }} - > - Insights - - + {isProToolsAvailable ? ( + + {isInsightsAuthorized ? ( + } + onClick={(event: MouseEvent) => { + event.stopPropagation() + dispatch(insightsModalDidOpen()) + }} + > + Insights + + ) : null} + {isMosaicAuthorized ? ( + } + onClick={(event: MouseEvent) => { + event.stopPropagation() + dispatch(mosaicModalDidOpen()) + }} + > + Mosaic + + ) : null} + {isWatermarkAuthorized ? ( + } + onClick={(event: MouseEvent) => { + event.stopPropagation() + dispatch(watermarkModalDidOpen()) + }} + > + Watermark + + ) : null} + ) : null} - {!isToolbarMode && isSharingAuthorized ? ( + {isProToolsAvailable ? : null} + {isManagementAvailable ? ( + + {isSharingAuthorized ? ( + } + onClick={(event: MouseEvent) => { + event.stopPropagation() + dispatch(sharingModalDidOpen()) + }} + > + Sharing + + ) : null} + {isSnapshotsAuthorized ? ( + } + onClick={(event: MouseEvent) => { + event.stopPropagation() + dispatch(listModalDidOpen()) + }} + > + Snapshots + + ) : null} + {isUploadAuthorized ? ( + } + onClick={(event: MouseEvent) => { + event.stopPropagation() + const singleId = file?.id + uploadInputRef?.current?.click() + if (singleId) { + dispatch(selectionUpdated([singleId])) + } + }} + > + Upload + + ) : null} + {isDownloadAuthorized ? ( + } + onClick={(event: MouseEvent) => { + event.stopPropagation() + if (file) { + downloadFile(file) + } + }} + > + Download + + ) : null} + + ) : null} + {isManagementAvailable ? : null} + } + icon={} + className={cx('text-red-500')} + isDisabled={!isDeleteAuthorized} onClick={(event: MouseEvent) => { event.stopPropagation() - dispatch(sharingModalDidOpen()) + dispatch(deleteModalDidOpen()) }} > - Sharing + Delete - ) : null} - {!isToolbarMode && isSnapshotsAuthorized ? ( } + icon={} + isDisabled={!isRenameAuthorized} onClick={(event: MouseEvent) => { event.stopPropagation() - dispatch(listModalDidOpen()) + dispatch(renameModalDidOpen()) }} > - Snapshots + Rename - ) : null} - {!isToolbarMode && isMosaicAuthorized ? ( } + icon={} + isDisabled={!isMoveAuthorized} onClick={(event: MouseEvent) => { event.stopPropagation() - dispatch(mosaicModalDidOpen()) + dispatch(moveModalDidOpen()) }} > - Mosaic + Move - ) : null} - {!isToolbarMode && isWatermarkAuthorized ? ( } + icon={} + isDisabled={!isCopyAuthorized} onClick={(event: MouseEvent) => { event.stopPropagation() - dispatch(watermarkModalDidOpen()) + dispatch(copyModalDidOpen()) }} > - Watermark + Copy - ) : null} - {isAnyFeatureAuthorized && !isToolbarMode ? : null} - } - isDisabled={!isUploadAuthorized} - onClick={(event: MouseEvent) => { - event.stopPropagation() - const singleId = file?.id - uploadInputRef?.current?.click() - if (singleId) { - dispatch(selectionUpdated([singleId])) - } - }} - > - Upload - - } - isDisabled={!isDownloadAuthorized} - onClick={(event: MouseEvent) => { - event.stopPropagation() - if (file) { - downloadFile(file) - } - }} - > - Download - - - } - className={cx('text-red-500')} - isDisabled={!isDeleteAuthorized} - onClick={(event: MouseEvent) => { - event.stopPropagation() - dispatch(deleteModalDidOpen()) - }} - > - Delete - - } - isDisabled={!isRenameAuthorized} - onClick={(event: MouseEvent) => { - event.stopPropagation() - dispatch(renameModalDidOpen()) - }} - > - Rename - - } - isDisabled={!isMoveAuthorized} - onClick={(event: MouseEvent) => { - event.stopPropagation() - dispatch(moveModalDidOpen()) - }} - > - Move - - } - isDisabled={!isCopyAuthorized} - onClick={(event: MouseEvent) => { - event.stopPropagation() - dispatch(copyModalDidOpen()) - }} - > - Copy - + {isToolbarMode ? ( - <> + } @@ -409,7 +383,7 @@ const FileMenu = ({ > Unselect All - + ) : null}