Skip to content

Commit

Permalink
skip anonymous sign in for bots
Browse files Browse the repository at this point in the history
  • Loading branch information
iswilljr committed Dec 13, 2024
1 parent 05ced21 commit 633859f
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 30 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"better-auth": "0.8.2-beta.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"isbot": "5.1.17",
"lucide-astro": "0.456.0",
"lucide-react": "^0.456.0",
"nanostores": "^0.11.3",
Expand Down
178 changes: 152 additions & 26 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/components/Auth/NavUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ async function handleLogout() {
window.location.reload()
}

export function NavUser() {
const { user, isLoading, isAuthenticated } = useSession()
export function NavUser({ isBot = false }) {
const { user, isLoading, isAuthenticated } = useSession({ isBot })

if (isLoading || !isAuthenticated) {
return <AuthDialog />
Expand Down
4 changes: 3 additions & 1 deletion src/components/Home/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import { NavUser } from '@/components/Auth/NavUser'
import { Search, SearchMobile } from '@/components/Search'
import { Search as SearchIcon, Telescope as PopcornIcon } from 'lucide-astro'
import { isbot } from 'isbot'
const pathname = Astro.url.pathname
const isBot = isbot(Astro.request.headers.get('user-agent')) || false
---

<header class='absolute inset-0 z-[99] h-16 w-full'>
Expand Down Expand Up @@ -36,7 +38,7 @@ const pathname = Astro.url.pathname
<PopcornIcon width='16' height='16' stroke='#000' />
<span class='sr-only'>Explore</span>
</a>
<NavUser client:idle />
<NavUser client:idle isBot={isBot} />
</div>
</div>
</header>
Loading

0 comments on commit 633859f

Please sign in to comment.