ldap-tfa: export * from pages/ldap

This commit is contained in:
vchikalkin 2024-07-14 16:04:22 +03:00
parent 60519a171a
commit e5b34e13d6
2 changed files with 9 additions and 17 deletions

View File

@ -1,14 +1 @@
import { PageHead } from './ldap';
import { Login } from '@/components';
import { FormStateProvider } from '@/context/form-state';
export default function Page(props) {
return (
<FormStateProvider {...props}>
<PageHead />
<Login tfa />
</FormStateProvider>
);
}
export { getServerSideProps } from './ldap';
export { default, getServerSideProps } from './ldap';

View File

@ -21,27 +21,32 @@ export default function Page(props) {
return (
<FormStateProvider {...props}>
<PageHead />
<Login />
<Login tfa={props.tfa} />
</FormStateProvider>
);
}
/** @type {import('next').GetServerSideProps} */
export async function getServerSideProps({ req }) {
const headers = pick(req.headers, ['auth-mode', 'cookie', 'refresh-token']);
const tfa = headers['auth-mode'] === 'ldap-tfa';
try {
const headers = pick(req.headers, ['auth-mode', 'cookie', 'refresh-token']);
const { data: user } = await axios.get(URL_API_CHECK_AUTH, {
headers,
});
return {
props: {
tfa,
user,
},
};
} catch {
return {
props: {},
props: {
tfa,
},
};
}
}