Skip to content

Commit

Permalink
fix: pass callbackURL, close #2630
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Jan 22, 2025
1 parent 500f0ba commit 85b00f7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions apps/renderer/src/modules/auth/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const formSchema = z.object({
password: z.string().max(128),
})

export function LoginWithPassword({ runtime }: { runtime?: LoginRuntime }) {
export function LoginWithPassword({ runtime }: { runtime: LoginRuntime }) {
const { t } = useTranslation("app")
const { t: tSettings } = useTranslation("settings")
const form = useForm<z.infer<typeof formSchema>>({
Expand All @@ -42,7 +42,7 @@ export function LoginWithPassword({ runtime }: { runtime?: LoginRuntime }) {
const { dismiss } = useCurrentModal()

async function onSubmit(values: z.infer<typeof formSchema>) {
const res = await loginHandler("credential", runtime ?? "browser", {
const res = await loginHandler("credential", runtime, {
email: values.email,
password: values.password,
})
Expand Down
4 changes: 2 additions & 2 deletions apps/renderer/src/modules/auth/LoginModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useAuthProviders } from "~/queries/users"
import { LoginWithPassword } from "./Form"

interface LoginModalContentProps {
runtime?: LoginRuntime
runtime: LoginRuntime
canClose?: boolean
}

Expand Down Expand Up @@ -196,7 +196,7 @@ const LoginButtonContent = (props: { children: React.ReactNode; isLoading: boole

export const AuthProvidersRender: FC<{
providers: AuthProvider[]
runtime?: LoginRuntime
runtime: LoginRuntime
}> = ({ providers, runtime }) => {
const { t } = useTranslation()
const [authProcessingLockSet, setAuthProcessingLockSet] = useState(() => new Set<string>())
Expand Down
3 changes: 1 addition & 2 deletions packages/shared/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const {
updateUser,
} = authClient

export const LOGIN_CALLBACK_URL = `${WEB_URL}/login`
export type LoginRuntime = "browser" | "app"
export const loginHandler = async (
provider: string,
Expand All @@ -80,7 +79,7 @@ export const loginHandler = async (

signIn.social({
provider: provider as "google" | "github" | "apple",
callbackURL: runtime === "app" ? LOGIN_CALLBACK_URL : undefined,
callbackURL: runtime === "app" ? `${WEB_URL}/login` : WEB_URL,
})
}
}

0 comments on commit 85b00f7

Please sign in to comment.