Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -4,19 +4,29 @@ import { APP_NAME } from "@renderer/lib/constants"
|
||||
import { useEffect, useState } from "react"
|
||||
import { useNavigate } from "react-router-dom"
|
||||
|
||||
const LOGIN_CALLBACK_URL = `${import.meta.env.VITE_WEB_URL}/redirect?app=follow`
|
||||
const loginHandler = (provider: string) => {
|
||||
if (window.electron) {
|
||||
window.open(
|
||||
`${import.meta.env.VITE_WEB_URL}/login?provider=${provider}`,
|
||||
)
|
||||
} else {
|
||||
signIn(provider, {
|
||||
callbackUrl: LOGIN_CALLBACK_URL,
|
||||
})
|
||||
}
|
||||
}
|
||||
export function Component() {
|
||||
const { status } = useSession()
|
||||
const navigate = useNavigate()
|
||||
const [redirecting, setRedirecting] = useState(false)
|
||||
|
||||
const callbackUrl = `${import.meta.env.VITE_WEB_URL}/redirect?app=follow`
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
const provider = urlParams.get("provider")
|
||||
useEffect(() => {
|
||||
if (!window.electron && provider) {
|
||||
signIn(provider, {
|
||||
callbackUrl,
|
||||
callbackUrl: LOGIN_CALLBACK_URL,
|
||||
})
|
||||
setRedirecting(true)
|
||||
}
|
||||
@@ -33,50 +43,38 @@ export function Component() {
|
||||
<h1 className="text-3xl font-bold">
|
||||
Log in to
|
||||
{" "}
|
||||
|
||||
{APP_NAME}
|
||||
</h1>
|
||||
{redirecting ?
|
||||
(
|
||||
<div>Redirecting</div>
|
||||
) :
|
||||
(
|
||||
<div className="flex flex-col gap-3">
|
||||
<Button
|
||||
className="text-lg"
|
||||
size="xl"
|
||||
onClick={() => {
|
||||
if (window.electron) {
|
||||
window.open(
|
||||
`${import.meta.env.VITE_WEB_URL}/login?provider=github`,
|
||||
)
|
||||
} else {
|
||||
signIn("github", {
|
||||
callbackUrl,
|
||||
})
|
||||
}
|
||||
}}
|
||||
>
|
||||
<i className="i-mingcute-github-fill mr-2 text-xl" />
|
||||
{" "}
|
||||
Continue with
|
||||
GitHub
|
||||
</Button>
|
||||
<Button
|
||||
className="bg-blue-500 text-lg hover:bg-blue-500/90"
|
||||
size="xl"
|
||||
onClick={() =>
|
||||
signIn("google", {
|
||||
callbackUrl,
|
||||
})}
|
||||
>
|
||||
<i className="i-mingcute-google-fill mr-2 text-xl" />
|
||||
{" "}
|
||||
Continue with
|
||||
Google
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{redirecting ? (
|
||||
<div>Redirecting</div>
|
||||
) : (
|
||||
<div className="flex flex-col gap-3">
|
||||
<Button
|
||||
className="bg-black text-lg text-white"
|
||||
size="xl"
|
||||
onClick={() => {
|
||||
loginHandler("github")
|
||||
}}
|
||||
>
|
||||
<i className="i-mingcute-github-fill mr-2 text-xl" />
|
||||
{" "}
|
||||
Continue with
|
||||
GitHub
|
||||
</Button>
|
||||
<Button
|
||||
className="bg-blue-500 text-lg text-white hover:bg-blue-500/90"
|
||||
size="xl"
|
||||
onClick={() => {
|
||||
loginHandler("google")
|
||||
}}
|
||||
>
|
||||
<i className="i-mingcute-google-fill mr-2 text-xl" />
|
||||
{" "}
|
||||
Continue with
|
||||
Google
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user