login-callback
This commit is contained in:
parent
ffb8dd5a23
commit
f0038acb61
2 changed files with 20 additions and 0 deletions
|
@ -122,6 +122,7 @@ export function initAuth(router: express.Router) {
|
|||
"/auth/oauth-callback",
|
||||
passport.authenticate("oauth2", { failureRedirect: "/", session: false }),
|
||||
(req: Request, res: Response) => {
|
||||
res.clearCookie("redir");
|
||||
if (req.user && req.user.apiKey) {
|
||||
res.redirect(
|
||||
req.cookies.redir
|
||||
|
|
19
revampdashboard/src/routes/login-callback/+server.ts
Normal file
19
revampdashboard/src/routes/login-callback/+server.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { redirect } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
export const GET: RequestHandler = async ({ url, cookies }) => {
|
||||
const apiKey = String(url.searchParams.get('apiKey') ?? '');
|
||||
const error = String(url.searchParams.get('error') ?? 'noAccess');
|
||||
|
||||
if (apiKey) {
|
||||
cookies.set('apiKey', apiKey, {
|
||||
httpOnly: true,
|
||||
path: '/new',
|
||||
secure: true,
|
||||
sameSite: 'strict'
|
||||
});
|
||||
return redirect(301, '/new/dashboard');
|
||||
} else {
|
||||
return redirect(301, `/new/?error=${error}`);
|
||||
}
|
||||
};
|
Loading…
Add table
Reference in a new issue