Skip to content

Test password protection#38

Merged
kyle-lesinger merged 6 commits intodevfrom
test-password-protection
Nov 18, 2025
Merged

Test password protection#38
kyle-lesinger merged 6 commits intodevfrom
test-password-protection

Conversation

@kyle-lesinger
Copy link
Contributor

No description provided.

kyle-lesinger and others added 5 commits November 18, 2025 16:20
The quarto-publish workflow was triggering on both 'main' and 'addContent'
branches. When a PR from addContent was opened, both workflows would run:
1. PR preview workflow would deploy to gh-pages/pr-preview/pr-XX/
2. Main deployment workflow would then overwrite the entire gh-pages branch

Now the workflow only triggers on 'main' branch pushes, allowing PR previews
to persist without being overwritten.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Updated auth-check.js to use dynamic path resolution instead of hardcoded
absolute paths. This ensures that:
- Main site redirects to /disasters-docs/password-protect.html
- PR previews redirect to /disasters-docs/pr-preview/pr-XX/password-protect.html

The getBasePath() function extracts the current directory path and constructs
the correct login page URL relative to the current location.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
ISSUE: The auth-check.js external script was not being included in
deployed HTML pages on PR previews, causing authentication to fail.

SOLUTION:
1. Inlined the entire auth-check.js content directly in _quarto.yml
   under include-in-header. This ensures the script is always embedded
   in every rendered HTML page.

2. Added verification step to both workflows (preview.yml and
   quarto-publish.yml) that checks for the presence of the auth script
   in rendered HTML before deployment. Build fails if script is missing.

This guarantees password protection works on all deployments:
- Main site (disasters-docs/)
- PR previews (disasters-docs/pr-preview/pr-XX/)
- Any future branch deployments

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
ISSUE: When visiting URLs like /disasters-docs/pr-preview/pr-37/ (without
index.html), the getBasePath() function couldn't find .html in the path,
so it fell back to the default /disasters-docs/, causing incorrect
redirects to the wrong password-protect.html location.

SOLUTION: Simplified getBasePath() to handle three cases:
1. Path ends with / → it's already the base directory
2. Path ends with .html → extract directory by removing filename
3. Otherwise → assume it's a directory, add trailing slash

This ensures correct redirects for all URL formats:
- /disasters-docs/pr-preview/pr-37/ → /disasters-docs/pr-preview/pr-37/password-protect.html
- /disasters-docs/pr-preview/pr-37/index.html → /disasters-docs/pr-preview/pr-37/password-protect.html
- /disasters-docs/ → /disasters-docs/password-protect.html

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@kyle-lesinger kyle-lesinger changed the base branch from main to dev November 18, 2025 23:11
@github-actions
Copy link

github-actions bot commented Nov 18, 2025

PR Preview Action v1.6.2

🚀 View preview at
https://Disasters-Learning-Portal.github.io/disasters-docs/pr-preview/pr-38/

Built to branch gh-pages at 2025-11-18 23:15 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@kyle-lesinger kyle-lesinger merged commit 4dd0405 into dev Nov 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant