Fix webhook URL protocol and add already-registered flow
Webhook URL is now built client-side using location.protocol so it correctly shows https when behind a reverse proxy. Added an 'Already registered?' toggle that lets users paste their full webhook URL to navigate directly to their settings page. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
1 parent
0b26fd86ad
commit
860381b3e9
1 file changed
+66
-2
+66
-2
@@ -224,6 +224,34 @@
|
|||||||
.manage-link a:hover { text-decoration: underline; }
|
.manage-link a:hover { text-decoration: underline; }
|
||||||
|
|
||||||
.hidden { display: none !important; }
|
.hidden { display: none !important; }
|
||||||
|
|
||||||
|
.alt-action {
|
||||||
|
margin-top: 20px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-alt {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: #6b7280;
|
||||||
|
font-size: 13px;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 4px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-alt:hover { color: #0082c9; }
|
||||||
|
|
||||||
|
#alreadyPanel {
|
||||||
|
margin-top: 14px;
|
||||||
|
text-align: left;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
padding-top: 14px;
|
||||||
|
border-top: 1px solid #f3f4f6;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -290,6 +318,19 @@
|
|||||||
<p class="manage-link hidden" id="manageLink">
|
<p class="manage-link hidden" id="manageLink">
|
||||||
Bookmark this page to return and update your settings.
|
Bookmark this page to return and update your settings.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<div class="alt-action" id="altAction">
|
||||||
|
<button type="button" class="btn-alt" onclick="toggleAlreadyRegistered(this)">
|
||||||
|
Already registered?
|
||||||
|
</button>
|
||||||
|
<div id="alreadyPanel" class="hidden">
|
||||||
|
<div class="field">
|
||||||
|
<label for="existingUrl">Paste your webhook URL</label>
|
||||||
|
<input type="url" id="existingUrl" placeholder="https://your-server/webhook/your-token" />
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn-submit" style="margin-top:0" onclick="goToSettings()">Go to my settings</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -319,6 +360,7 @@
|
|||||||
pwField.required = false
|
pwField.required = false
|
||||||
|
|
||||||
document.getElementById('adminSection').classList.add('hidden')
|
document.getElementById('adminSection').classList.add('hidden')
|
||||||
|
document.getElementById('altAction').classList.add('hidden')
|
||||||
document.getElementById('submitBtn').textContent = 'Update settings'
|
document.getElementById('submitBtn').textContent = 'Update settings'
|
||||||
document.getElementById('subtitle').textContent = 'Update your integration settings'
|
document.getElementById('subtitle').textContent = 'Update your integration settings'
|
||||||
|
|
||||||
@@ -366,8 +408,8 @@
|
|||||||
data = await res.json()
|
data = await res.json()
|
||||||
if (!res.ok) throw new Error(data.error)
|
if (!res.ok) throw new Error(data.error)
|
||||||
|
|
||||||
webhookUrlValue = data.webhookUrl
|
webhookUrlValue = `${location.protocol}//${location.host}/webhook/${data.token}`
|
||||||
showWebhookBanner(data.webhookUrl)
|
showWebhookBanner(webhookUrlValue)
|
||||||
|
|
||||||
const manageUrl = `${location.protocol}//${location.host}/?token=${data.token}`
|
const manageUrl = `${location.protocol}//${location.host}/?token=${data.token}`
|
||||||
document.getElementById('manageLink').innerHTML =
|
document.getElementById('manageLink').innerHTML =
|
||||||
@@ -414,6 +456,28 @@
|
|||||||
function clearAlert() {
|
function clearAlert() {
|
||||||
document.getElementById('alertBox').classList.add('hidden')
|
document.getElementById('alertBox').classList.add('hidden')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleAlreadyRegistered(btn) {
|
||||||
|
const panel = document.getElementById('alreadyPanel')
|
||||||
|
const opening = panel.classList.contains('hidden')
|
||||||
|
panel.classList.toggle('hidden')
|
||||||
|
btn.textContent = opening ? 'Cancel' : 'Already registered?'
|
||||||
|
}
|
||||||
|
|
||||||
|
function goToSettings() {
|
||||||
|
const input = document.getElementById('existingUrl').value.trim()
|
||||||
|
try {
|
||||||
|
const url = new URL(input)
|
||||||
|
const parts = url.pathname.split('/').filter(Boolean)
|
||||||
|
const webhookIdx = parts.indexOf('webhook')
|
||||||
|
if (webhookIdx === -1 || !parts[webhookIdx + 1]) {
|
||||||
|
throw new Error('Could not find a token in that URL.')
|
||||||
|
}
|
||||||
|
location.href = `/?token=${encodeURIComponent(parts[webhookIdx + 1])}`
|
||||||
|
} catch (e) {
|
||||||
|
showAlert('error', e.message.startsWith('Could not') ? e.message : 'Please enter a valid webhook URL.')
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in new issue
Block a user