CenterForDigitalHumanities / CenterForDigitalHumanities/TPEN-interfaces

'View Full Page' Inspect Tool Gets Stuck In Login Loop

Open
#563 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
2
Forks
3
PR merge metrics
No merged PRs in 30d

Description

It gets stuck in a login loop when clicked. This issue is actually in the interfaces component.

**Suggested Fix**
In magnifier-tool/index.js: drop the attachAuthentication / onProjectReady / CheckPermissions calls. The magnifier needs no project context and no auth — it operates purely on the imageElem it's handed.

New lifecycle:
```javascript
connectedCallback() {
this.render()
this.addEventListeners()
}

disconnectedCallback() {
this.renderCleanup.run()
this.cleanup.run()
}
```
This kills the loop at the source and also makes MagnifierTool safely embeddable in any context (the workspace toolbar, Page-Viewer, future tools).

**Additional Optional Fixes**
components/simple-transcription/index.js:1146-1155 — don't call TPEN.login() from a postMessage handler.

```javascript
#sendIdTokenToTool(targetWindow = ...) {
const idToken = TPEN.getAuthorization()
if (!idToken) {
TPEN.login() // <-- this nukes the parent window
return
}
...
}
```
Replace with a postMessage reply telling the tool no token is available, and let the tool decide what to do. Otherwise any future tool iframe that sends REQUEST_TPEN_ID_TOKEN while the parent's token is expired will trigger the same kind of redirect loop.

```javascript
#sendIdTokenToTool(targetWindow = ...) {
const idToken = TPEN.getAuthorization()
if (!idToken) {
this.#postToTool({ type: 'TPEN_ID_TOKEN_UNAVAILABLE' }, targetWindow)
return
}
...
}
```

### https://github.com/CenterForDigitalHumanities/Page-Viewer Minor Cleanup

message-handler.js:55-57 — Page-Viewer is set up to receive REQUEST_TPEN_ID_TOKEN (a parent→tool message it would never get) rather than send it. The case is harmless but misleading. Either delete the case entirely, or replace it with a comment that Page-Viewer never sends or receives that message.

Not a bug — just dead code that sent me down the wrong trail earlier.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.