jbilcke-hf's picture
jbilcke-hf HF staff
working on the Hugging Face Sign-In
0ed5b20
raw
history blame
No virus
689 Bytes
"use client"
import { useEffect } from "react"
import { Button } from "@/components/ui/button"
import { useOAuth } from "@/lib/useOAuth"
export function Login() {
const { canLogin, login, isLoggedIn, oauthResult } = useOAuth({ debug: true })
useEffect(() => {
if (!oauthResult) {
return
}
const { userInfo } = oauthResult
// TODO use the Inference API
if (userInfo.isPro) {
// TODO we could do something with the fact the user is PRO versus other types of users
}
}, [canLogin, isLoggedIn, oauthResult])
if (isLoggedIn || canLogin) {
return <Button onClick={login}>Sign-in with Hugging Face</Button>
} else {
return null
}
}