Skip to content

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

Open
wants to merge 1 commit into
base: yemq-add-local-google-one-tap
Choose a base branch
from

Conversation

darcyYe
Copy link
Contributor

@darcyYe darcyYe commented May 29, 2025

Summary

Add auth status check, resolves LOG-11509

@darcyYe darcyYe requested review from a team and Copilot May 29, 2025 04:04
Copy link
Contributor

@Copilot Copilot AI left a 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(() => {
Copy link
Preview

Copilot AI May 29, 2025

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.

@darcyYe darcyYe force-pushed the yemq-add-auth-status-check branch from aa6815f to 8087b48 Compare May 29, 2025 04:05
Copy link

cloudflare-workers-and-pages bot commented May 29, 2025

Deploying logto-docs-tutorials with  Cloudflare Pages  Cloudflare Pages

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

View logs

Copy link

cloudflare-workers-and-pages bot commented May 29, 2025

Deploying logto-docs with  Cloudflare Pages  Cloudflare Pages

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

View logs

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]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}, [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),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double check this one

Comment on lines +41 to +42
const [authStatus, setAuthStatus] = useState<boolean | undefined>(undefined);
const [authCheckError, setAuthCheckError] = useState<string | undefined>(undefined);
Copy link
Member

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:

Suggested change
const [authStatus, setAuthStatus] = useState<boolean | undefined>(undefined);
const [authCheckError, setAuthCheckError] = useState<string | undefined>(undefined);
const [authStatus, setAuthStatus] = useState<boolean>();
const [authCheckError, setAuthCheckError] = useState<string>();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants