Skip to content

Commit

Permalink
fix(auth): handle optional icon class names for providers in login co…
Browse files Browse the repository at this point in the history
…mponents

- Updated the LoginModalContent and Login components to safely access provider icon class names using optional chaining.
- Excluded the "credential" provider from the list of displayed auth providers to streamline the login options.

Signed-off-by: Innei <tukon479@gmail.com>
  • Loading branch information
Innei committed Dec 16, 2024
1 parent e0661ff commit de8d337
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions apps/renderer/src/modules/auth/LoginModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const LoginModalContent = (props: LoginModalContentProps) => {
const extraProviders = useMemo(() => {
if (!authProviders) return []
return Object.entries(authProviders)
.filter(([key]) => !defaultProviders[key])
.filter(([key]) => !defaultProviders[key] && key !== "credential")
.map(([_, provider]) => provider)
}, [authProviders])

Expand Down Expand Up @@ -116,7 +116,9 @@ export const LoginModalContent = (props: LoginModalContentProps) => {
}}
>
<LoginButtonContent isLoading={loadingLockSet === provider.id}>
<i className={clsx("mr-2 text-xl", authProvidersConfig[provider.id].iconClassName)} />{" "}
<i
className={clsx("mr-2 text-xl", authProvidersConfig[provider.id]?.iconClassName)}
/>{" "}
{t("signin.continue_with", { provider: provider.name })}
</LoginButtonContent>
</MotionButtonBase>
Expand Down
2 changes: 1 addition & 1 deletion apps/server/client/modules/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export function Login() {
loginHandler(key)
}}
>
<i className={cn("mr-2 text-xl", authProvidersConfig[key].iconClassName)} />{" "}
<i className={cn("mr-2 text-xl", authProvidersConfig[key]?.iconClassName)} />{" "}
{t("login.continueWith", { provider: provider.name })}
</Button>
))}
Expand Down

0 comments on commit de8d337

Please sign in to comment.