2024-12-31 10:31:50 +05:30
|
|
|
import { type ActionFunctionArgs, redirect } from 'react-router';
|
2025-03-22 01:36:27 -04:00
|
|
|
import type { LoadContext } from '~/server';
|
2024-03-30 02:44:06 -04:00
|
|
|
|
2024-12-08 13:27:51 -05:00
|
|
|
export async function loader() {
|
2024-12-31 10:30:14 +05:30
|
|
|
return redirect('/machines');
|
2024-12-08 13:27:51 -05:00
|
|
|
}
|
|
|
|
|
|
2025-03-22 01:36:27 -04:00
|
|
|
export async function action({
|
|
|
|
|
request,
|
|
|
|
|
context,
|
|
|
|
|
}: ActionFunctionArgs<LoadContext>) {
|
2025-08-19 17:49:32 -04:00
|
|
|
try {
|
|
|
|
|
await context.sessions.auth(request);
|
|
|
|
|
} catch {
|
|
|
|
|
redirect('/login');
|
2025-03-22 01:36:27 -04:00
|
|
|
}
|
|
|
|
|
|
2025-04-03 12:25:15 -04:00
|
|
|
// When API key is disabled, we need to explicitly redirect
|
|
|
|
|
// with a logout state to prevent auto login again.
|
|
|
|
|
const url = context.config.oidc?.disable_api_key_login
|
|
|
|
|
? '/login?s=logout'
|
|
|
|
|
: '/login';
|
|
|
|
|
|
|
|
|
|
return redirect(url, {
|
2024-03-30 02:44:06 -04:00
|
|
|
headers: {
|
2025-08-19 17:49:32 -04:00
|
|
|
'Set-Cookie': await context.sessions.destroySession(),
|
2024-12-31 10:30:14 +05:30
|
|
|
},
|
|
|
|
|
});
|
2024-03-30 02:44:06 -04:00
|
|
|
}
|