Skip to content

Commit 6075b0d

Browse files
committed
Revert auto-login: remove /api/servers/auto-login endpoint, simplify openPyrodactylPanel to direct URL open
1 parent 0b35973 commit 6075b0d

2 files changed

Lines changed: 6 additions & 41 deletions

File tree

public/js/app.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ function renderCookieBanner() {
4545
});
4646
}
4747

48-
async function openPyrodactylPanel(serverIdentifier) {
49-
const data = await api('/servers/auto-login');
50-
let url = data.autoLogin
51-
? `${data.panelUrl}/auth/login?token=${data.token}${serverIdentifier ? `&redirect=${encodeURIComponent('/server/' + serverIdentifier)}` : ''}`
52-
: `${data.panelUrl}${serverIdentifier ? '/server/' + serverIdentifier : ''}`;
48+
const PTERO_URL = 'https://ptero.zerohost.fr';
49+
50+
function openPyrodactylPanel(serverIdentifier) {
51+
const url = `${PTERO_URL}${serverIdentifier ? '/server/' + serverIdentifier : ''}`;
5352
window.open(url, '_blank');
5453
}
5554

@@ -1289,7 +1288,7 @@ function renderPyrodactyl() {
12891288
el.innerHTML = html`
12901289
<div class="page-header">
12911290
<h1 class="page-title">Pyrodactyl Panel</h1>
1292-
<p class="page-subtitle">Opening Pyrodactyl with auto-login...</p>
1291+
<p class="page-subtitle">Access your Pyrodactyl panel</p>
12931292
</div>
12941293
<div class="ptero-grid">
12951294
<div class="card ptero-card">
@@ -1298,7 +1297,7 @@ function renderPyrodactyl() {
12981297
</div>
12991298
<h2 class="ptero-card-title">Opening Pyrodactyl...</h2>
13001299
<p class="ptero-card-desc">
1301-
You are being automatically logged in to the Pyrodactyl panel. If nothing happens, click the button below.
1300+
Click the button below to open the Pyrodactyl panel.
13021301
</p>
13031302
<button class="btn btn-primary btn-full" id="ptero-open-btn" onclick="openPyrodactylPanel()">
13041303
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6M15 3h6v6M10 14L21 3"/></svg>

routes/servers.js

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -390,40 +390,6 @@ router.get('/resources/:identifier', authenticateToken, async (req, res) => {
390390
}
391391
});
392392

393-
router.get('/auto-login', authenticateToken, async (req, res) => {
394-
try {
395-
const userId = req.user.userId;
396-
const users = await query('SELECT ptero_client_api_key FROM users WHERE id = ?', [userId]);
397-
398-
if (!users[0]?.ptero_client_api_key) {
399-
return res.json({ autoLogin: false, panelUrl: PTERO_URL });
400-
}
401-
402-
const apiKey = users[0].ptero_client_api_key;
403-
const pteroRes = await fetch(`${PTERO_URL}/api/client/account/one-time-token`, {
404-
method: 'POST',
405-
headers: {
406-
'Authorization': `Bearer ${apiKey}`,
407-
'Accept': 'application/json',
408-
'Content-Type': 'application/json',
409-
},
410-
signal: AbortSignal.timeout(10000),
411-
});
412-
413-
if (!pteroRes.ok) {
414-
return res.json({ autoLogin: false, panelUrl: PTERO_URL });
415-
}
416-
417-
const data = await pteroRes.json();
418-
const token = data.attributes?.token || data.token;
419-
420-
res.json({ autoLogin: true, token, panelUrl: PTERO_URL });
421-
} catch (err) {
422-
console.error('Auto-login error:', err.message);
423-
res.status(500).json({ error: 'Failed to generate auto-login link' });
424-
}
425-
});
426-
427393
router.put('/client-api-key', authenticateToken, async (req, res) => {
428394
try {
429395
const { apiKey } = req.body;

0 commit comments

Comments
 (0)