mirror of
https://github.com/diced/zipline.git
synced 2025-04-11 23:31:17 -05:00
Merge branch 'trunk' into trunk
This commit is contained in:
commit
ce084eb72a
5 changed files with 43 additions and 12 deletions
|
@ -357,7 +357,9 @@ export default function Layout({ children, config }: { children: React.ReactNode
|
|||
}
|
||||
})}
|
||||
|
||||
<ScrollArea mah={200} mt='auto'>
|
||||
<Divider mt='auto' />
|
||||
|
||||
<ScrollArea mah='auto'>
|
||||
<Box>
|
||||
{config.website.externalLinks.map(({ name, url }, i) => (
|
||||
<NavLink
|
||||
|
|
|
@ -40,6 +40,7 @@ export function settingsOnSubmit(router: NextRouter, form: ReturnType<typeof use
|
|||
});
|
||||
|
||||
await fetch('/reload');
|
||||
await fetch('/api/reload');
|
||||
mutate('/api/server/settings', data);
|
||||
router.replace(router.asPath, undefined, { scroll: false });
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ export default function ImportButton() {
|
|||
});
|
||||
|
||||
await fetch('/reload');
|
||||
await fetch('/api/reload');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
25
src/pages/api/reload.ts
Normal file
25
src/pages/api/reload.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { reloadSettings } from '@/lib/config';
|
||||
import { prisma } from '@/lib/db';
|
||||
import { isAdministrator } from '@/lib/role';
|
||||
import { getSession } from '@/server/session';
|
||||
import { NextApiRequest, NextApiResponse } from 'next/types';
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const session = await getSession(req, res);
|
||||
if (!session.id || !session.sessionId) return res.redirect(302, '/auth/login');
|
||||
|
||||
const user = await prisma.user.findFirst({
|
||||
where: {
|
||||
sessions: {
|
||||
has: session.sessionId,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!user) return res.redirect(302, '/dashboard');
|
||||
if (!isAdministrator(user.role)) return res.redirect(302, '/dashboard');
|
||||
|
||||
await reloadSettings();
|
||||
|
||||
return res.json({ success: true });
|
||||
}
|
|
@ -296,17 +296,19 @@ export default function Login({ config }: InferGetServerSidePropsType<typeof get
|
|||
<Divider label='or' />
|
||||
)}
|
||||
|
||||
<Button
|
||||
onClick={handlePasskeyLogin}
|
||||
size='md'
|
||||
fullWidth
|
||||
variant='outline'
|
||||
leftSection={<IconKey size='1rem' />}
|
||||
color={passkeyErrored ? 'red' : undefined}
|
||||
loading={passkeyLoading}
|
||||
>
|
||||
Login with passkey
|
||||
</Button>
|
||||
{config.mfa.passkeys && (
|
||||
<Button
|
||||
onClick={handlePasskeyLogin}
|
||||
size='md'
|
||||
fullWidth
|
||||
variant='outline'
|
||||
leftSection={<IconKey size='1rem' />}
|
||||
color={passkeyErrored ? 'red' : undefined}
|
||||
loading={passkeyLoading}
|
||||
>
|
||||
Login with passkey
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{config.features.userRegistration && (
|
||||
<Button
|
||||
|
|
Loading…
Add table
Reference in a new issue