Accesso al Biohacking dal menu del sito e dal login pubblico
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
import { site } from '../data/site';
|
import { site } from '../data/site';
|
||||||
import { t, contentImageUrl } from '../lib/content';
|
import { t, contentImageUrl } from '../lib/content';
|
||||||
|
import { landingFor } from '../lib/auth';
|
||||||
interface Props {
|
interface Props {
|
||||||
user: { username: string; role: string } | null;
|
user: { username: string; role: string } | null;
|
||||||
showTags: boolean;
|
showTags: boolean;
|
||||||
@@ -9,7 +10,9 @@ interface Props {
|
|||||||
const { user, canTags, showTags } = Astro.props;
|
const { user, canTags, showTags } = Astro.props;
|
||||||
const path = Astro.url.pathname;
|
const path = Astro.url.pathname;
|
||||||
const loginHref = `/login?next=${encodeURIComponent(path)}`;
|
const loginHref = `/login?next=${encodeURIComponent(path)}`;
|
||||||
const areaHref = user?.role === 'superuser' ? '/admin/content' : '/admin';
|
const areaHref = user ? landingFor(user.role) : '/admin';
|
||||||
|
// La sezione Biohacking compare nel menu solo a chi può davvero aprirla.
|
||||||
|
const canBiohacking = user?.role === 'campus' || user?.role === 'admin';
|
||||||
---
|
---
|
||||||
<header class="hdr" id="site-header">
|
<header class="hdr" id="site-header">
|
||||||
<div class="container hdr__in">
|
<div class="container hdr__in">
|
||||||
@@ -20,6 +23,9 @@ const areaHref = user?.role === 'superuser' ? '/admin/content' : '/admin';
|
|||||||
<a href={item.href} class:list={['hdr__link', { 'is-active': path === item.href || (item.href !== '/' && path.startsWith(item.href)) }]}>{t(`global.nav.${i + 1}.label`)}</a>
|
<a href={item.href} class:list={['hdr__link', { 'is-active': path === item.href || (item.href !== '/' && path.startsWith(item.href)) }]}>{t(`global.nav.${i + 1}.label`)}</a>
|
||||||
)
|
)
|
||||||
))}
|
))}
|
||||||
|
{canBiohacking && (
|
||||||
|
<a href="/campus" class:list={['hdr__link', 'hdr__link--bio', { 'is-active': path.startsWith('/campus') }]}>Biohacking</a>
|
||||||
|
)}
|
||||||
</nav>
|
</nav>
|
||||||
<div class="hdr__user">
|
<div class="hdr__user">
|
||||||
{user ? (
|
{user ? (
|
||||||
@@ -50,6 +56,7 @@ const areaHref = user?.role === 'superuser' ? '/admin/content' : '/admin';
|
|||||||
.hdr__nav { display: flex; gap: 34px; }
|
.hdr__nav { display: flex; gap: 34px; }
|
||||||
.hdr__link { font-family: var(--font-heading); font-size: .72rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; text-decoration: none; color: var(--c-heading); transition: color .3s ease; }
|
.hdr__link { font-family: var(--font-heading); font-size: .72rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; text-decoration: none; color: var(--c-heading); transition: color .3s ease; }
|
||||||
.hdr__link:hover, .hdr__link.is-active { color: var(--c-accent-dark); }
|
.hdr__link:hover, .hdr__link.is-active { color: var(--c-accent-dark); }
|
||||||
|
.hdr__link--bio { color: var(--c-accent-dark); }
|
||||||
.hdr__burger { display: none; background: none; border: 0; cursor: pointer; padding: 8px; }
|
.hdr__burger { display: none; background: none; border: 0; cursor: pointer; padding: 8px; }
|
||||||
.hdr__burger span { display: block; width: 22px; height: 2px; background: var(--c-heading); margin: 5px 0; }
|
.hdr__burger span { display: block; width: 22px; height: 2px; background: var(--c-heading); margin: 5px 0; }
|
||||||
@media (max-width: 991px) {
|
@media (max-width: 991px) {
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ export const onRequest = defineMiddleware((context, next) => {
|
|||||||
status: 401, headers: { 'Content-Type': 'application/json' },
|
status: 401, headers: { 'Content-Type': 'application/json' },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// La sezione Biohacking si raggiunge dal sito, quindi passa dal login
|
||||||
|
// pubblico e ci torna dopo l'accesso; il pannello ha il proprio.
|
||||||
|
if (pathname.startsWith('/campus'))
|
||||||
|
return context.redirect(`/login?next=${encodeURIComponent(pathname)}`);
|
||||||
return context.redirect('/admin/login');
|
return context.redirect('/admin/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user