fix: pass callbackURL, close #2630
This commit is contained in:
@@ -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>>({
|
||||
@@ -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,
|
||||
})
|
||||
|
||||
@@ -19,7 +19,7 @@ import { useAuthProviders } from "~/queries/users"
|
||||
import { LoginWithPassword } from "./Form"
|
||||
|
||||
interface LoginModalContentProps {
|
||||
runtime?: LoginRuntime
|
||||
runtime: LoginRuntime
|
||||
canClose?: boolean
|
||||
}
|
||||
|
||||
@@ -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>())
|
||||
|
||||
@@ -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,
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user