1
0
mirror of synced 2026-01-23 21:03:52 -05:00

Merge pull request #19717 from github/repo-sync

repo sync
This commit is contained in:
Octomerger Bot
2022-08-12 14:59:28 -04:00
committed by GitHub
4 changed files with 24 additions and 9 deletions

View File

@@ -0,0 +1,20 @@
import { useState, useEffect } from 'react'
import Cookies from 'js-cookie'
// Measure if the user has a github.com account and signed in during this session.
// The github.com sends the color_mode cookie every request when you sign in,
// but does not delete the color_mode cookie on sign out.
// You do not need to change your color mode settings to get this cookie,
// this applies to every user regardless of if they changed this setting.
// To test this, try a private browser tab.
// We are using the color_mode cookie because it is not HttpOnly.
export function useHasAccount() {
const [hasAccount, setHasAccount] = useState<boolean | null>(null)
useEffect(() => {
const cookieValue = Cookies.get('color_mode')
setHasAccount(Boolean(cookieValue))
}, [])
return { hasAccount }
}

View File

@@ -10,7 +10,6 @@ export default async function fetcher<JSON = any>(
}
export type Session = {
isSignedIn: boolean
csrfToken?: string
}

View File

@@ -6,7 +6,7 @@ import { useVersion } from 'components/hooks/useVersion'
import { Link } from 'components/Link'
import { useMainContext } from 'components/context/MainContext'
import { useSession } from 'components/hooks/useSession'
import { useHasAccount } from 'components/hooks/useHasAccount'
import { LanguagePicker } from './LanguagePicker'
import { HeaderNotifications } from 'components/page-header/HeaderNotifications'
import { ProductPicker } from 'components/page-header/ProductPicker'
@@ -26,11 +26,10 @@ export const Header = () => {
)
const [scroll, setScroll] = useState(false)
const { session } = useSession()
const { hasAccount } = useHasAccount()
const signupCTAVisible =
session &&
!session.isSignedIn &&
hasAccount === false && // don't show if `null`
(currentVersion === 'free-pro-team@latest' || currentVersion === 'enterprise-cloud@latest')
useEffect(() => {

View File

@@ -6,10 +6,7 @@ const noCacheControl = cacheControlFactory(0)
router.get('/', (req, res) => {
noCacheControl(res)
res.json({
isSignedIn: Boolean(req.cookies?.dotcom_user),
csrfToken: req.csrfToken?.() || '',
})
res.json({ csrfToken: req.csrfToken?.() || '' })
})
export default router