-
-
Notifications
You must be signed in to change notification settings - Fork 42
feat: check auth status on cloud console #1126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: yemq-add-local-google-one-tap
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a cross-domain authentication status check that verifies admin token validity using an iframe-based approach and integrates it into the Docusaurus layout. Key changes include:
- Adding new types and enum definitions for auth status checking in src/theme/Layout/types.ts.
- Implementing the auth status check mechanism, including debug logging, polling, and global exposure of auth state in src/theme/Layout/index.tsx.
- Updating the Docusaurus configuration to support the new auth status check feature via new customFields.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/theme/Layout/types.ts | Added types and enums to define the cross-domain auth status check functionality. |
src/theme/Layout/index.tsx | Integrated auth status checking into the layout with appropriate debug logging and polling. |
docusaurus.config.ts | Updated customFields to include new environment variables for the auth status check feature. |
if (isIframeVisible) { | ||
// In debug mode, delay removal to allow inspection | ||
iframe.style.border = '2px solid green'; // Change border color to indicate success | ||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider extracting the various timeout durations (e.g., 5000ms and 10000ms) into named constants for better maintainability and consistency across the auth status check implementation.
Copilot uses AI. Check for mistakes.
aa6815f
to
8087b48
Compare
Deploying logto-docs-tutorials with
|
Latest commit: |
8087b48
|
Status: | ✅ Deploy successful! |
Preview URL: | https://5d50b551.logto-docs-tutorials.pages.dev |
Branch Preview URL: | https://yemq-add-auth-status-check.logto-docs-tutorials.pages.dev |
Deploying logto-docs with
|
Latest commit: |
8087b48
|
Status: | ✅ Deploy successful! |
Preview URL: | https://180bfede.logto-docs.pages.dev |
Branch Preview URL: | https://yemq-add-auth-status-check.logto-docs.pages.dev |
const validatedConfig = googleOneTapConfigSchema.parse(data); | ||
|
||
localStorage.setItem(CACHE_KEY, JSON.stringify(validatedConfig)); | ||
localStorage.setItem(CACHE_EXPIRY_KEY, String(Date.now() + CACHE_EXPIRY_TIME)); | ||
|
||
setConfig(validatedConfig); | ||
} catch (error) { | ||
console.error('Error fetching or validating Google One Tap config:', error); | ||
debugLogger.error('Error fetching or validating Google One Tap config:', error); | ||
} | ||
}; | ||
|
||
void fetchConfig(); | ||
}, [apiBaseUrl]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}, [apiBaseUrl]); | |
}, [apiBaseUrl, debugLogger]); |
@@ -54,7 +55,10 @@ const config: Config = { | |||
customFields: { | |||
inkeepApiKey: process.env.INKEEP_API_KEY, | |||
logtoApiBaseUrl: process.env.LOGTO_API_BASE_URL, | |||
isDevFeatureEnabled: yes(process.env.IS_DEV_FEATURE_ENABLED), | |||
isDevFeatureEnabled: yes(process.env.IS_DEV_FEATURE_ENABLED ?? null), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double check this one
const [authStatus, setAuthStatus] = useState<boolean | undefined>(undefined); | ||
const [authCheckError, setAuthCheckError] = useState<string | undefined>(undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can be simplified to:
const [authStatus, setAuthStatus] = useState<boolean | undefined>(undefined); | |
const [authCheckError, setAuthCheckError] = useState<string | undefined>(undefined); | |
const [authStatus, setAuthStatus] = useState<boolean>(); | |
const [authCheckError, setAuthCheckError] = useState<string>(); |
Summary
Add auth status check, resolves LOG-11509