Portal: Mitarbeiter-Login gesperrt (Hinweis aufs Ticketsystem), alte Mitarbeiter-Sitzungen enden
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d0ca3c41cd
commit
3a4fa581c0
13 files changed
+145
-559
No files matched your search
@@ -45,39 +45,6 @@ test('switch-link: Mitarbeiter ohne Admin-Label bekommt einen Link', async () =>
|
||||
assert.match(res.body.openUrl, /^https:\/\/project\.webklar\.com\/api\/auth\/staff-switch\?token=[0-9a-f]{64}$/)
|
||||
})
|
||||
|
||||
test('staff-switch: gueltig -> Admin-Sitzung und /admin.html, zweites Mal -> Login', async () => {
|
||||
const { body } = await switchLink('jwt-staff')
|
||||
const path = `/api/auth/staff-switch?token=${tokenOf(body.openUrl)}`
|
||||
const res = await rawGet(path)
|
||||
assert.equal(res.status, 302)
|
||||
assert.equal(res.headers.get('location'), '/admin.html')
|
||||
const session = portalSession(res)
|
||||
assert.equal(session.role, 'admin')
|
||||
assert.equal(session.isAdmin, false)
|
||||
assert.equal(session.appwriteUserId, 'u_staff2')
|
||||
const again = await rawGet(path)
|
||||
assert.equal(again.status, 302)
|
||||
assert.equal(again.headers.get('location'), '/login.html?error=Link%20abgelaufen%2C%20bitte%20anmelden')
|
||||
assert.equal(portalSession(again), null)
|
||||
})
|
||||
|
||||
test('staff-switch: nach 61 Sekunden abgelaufen', async (t) => {
|
||||
const { body } = await switchLink('jwt-staff')
|
||||
const now = Date.now()
|
||||
t.mock.method(Date, 'now', () => now + 61 * 1000)
|
||||
const res = await rawGet(`/api/auth/staff-switch?token=${tokenOf(body.openUrl)}`)
|
||||
assert.match(res.headers.get('location'), /^\/login\.html\?error=/)
|
||||
})
|
||||
|
||||
test('Tokens nicht vertauschbar: Switch ueber staff-preview, Preview ueber staff-switch', async () => {
|
||||
const { body } = await switchLink('jwt-staff')
|
||||
assert.equal((await rawGet(`/api/auth/staff-preview?token=${tokenOf(body.openUrl)}`)).status, 410)
|
||||
const previewToken = createStaffPreviewToken({ userId: 'u_admin', email: 'kenso@webklar.com', name: 'Kenso', previewUrl: 'https://x.project.webklar.com/' })
|
||||
const res = await rawGet(`/api/auth/staff-switch?token=${previewToken}`)
|
||||
assert.match(res.headers.get('location'), /^\/login\.html\?error=/)
|
||||
assert.equal(portalSession(res), null)
|
||||
})
|
||||
|
||||
test('admin.html: Rueckweg ins Ticketsystem in der Kopfzeile', () => {
|
||||
const html = readFileSync(new URL('../public/admin.html', import.meta.url), 'utf8')
|
||||
const actions = html.slice(html.indexOf('portal-header-actions'), html.indexOf('id="logout-btn"'))
|
||||
|
||||
Reference in new issue
Block a user