mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-10 20:56:39 +00:00
set public next env vars from config
This commit is contained in:
@@ -118,7 +118,7 @@ export async function login(
|
||||
|
||||
const session = await lucia.createSession(existingUser.id, {});
|
||||
const cookie = lucia.createSessionCookie(session.id).serialize();
|
||||
logger.debug("Session cookie", JSON.stringify(cookie, null, 2));
|
||||
|
||||
res.appendHeader(
|
||||
"Set-Cookie",
|
||||
cookie
|
||||
|
||||
@@ -37,7 +37,10 @@ export function buildTraefikConfig(
|
||||
[middlewareName]: {
|
||||
plugin: {
|
||||
[middlewareName]: {
|
||||
apiBaseUrl: config.app.internal_base_url,
|
||||
apiBaseUrl: new URL(
|
||||
"/api/v1",
|
||||
`http://${config.server.internal_hostname}:${config.server.internal_port}`,
|
||||
).href,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,24 +1,36 @@
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
import { z } from 'zod';
|
||||
import { db } from '@server/db';
|
||||
import { users } from '@server/db/schema';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { z } from "zod";
|
||||
import { db } from "@server/db";
|
||||
import { users } from "@server/db/schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import response from "@server/utils/response";
|
||||
import HttpCode from '@server/types/HttpCode';
|
||||
import createHttpError from 'http-errors';
|
||||
import { ActionsEnum, checkUserActionPermission } from '@server/auth/actions';
|
||||
import logger from '@server/logger';
|
||||
import HttpCode from "@server/types/HttpCode";
|
||||
import createHttpError from "http-errors";
|
||||
import { ActionsEnum, checkUserActionPermission } from "@server/auth/actions";
|
||||
import logger from "@server/logger";
|
||||
|
||||
export type GetUserResponse = {
|
||||
email: string;
|
||||
twoFactorEnabled: boolean;
|
||||
emailVerified: boolean;
|
||||
};
|
||||
|
||||
export async function getUser(req: Request, res: Response, next: NextFunction): Promise<any> {
|
||||
export async function getUser(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction,
|
||||
): Promise<any> {
|
||||
try {
|
||||
const userId = req.user?.id;
|
||||
|
||||
|
||||
if (!userId) {
|
||||
return next(createHttpError(HttpCode.UNAUTHORIZED, "User not found"));
|
||||
return next(
|
||||
createHttpError(HttpCode.UNAUTHORIZED, "User not found"),
|
||||
);
|
||||
}
|
||||
|
||||
const user = await db.select()
|
||||
const user = await db
|
||||
.select()
|
||||
.from(users)
|
||||
.where(eq(users.id, userId))
|
||||
.limit(1);
|
||||
@@ -27,16 +39,16 @@ export async function getUser(req: Request, res: Response, next: NextFunction):
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.NOT_FOUND,
|
||||
`User with ID ${userId} not found`
|
||||
)
|
||||
`User with ID ${userId} not found`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return response(res, {
|
||||
return response<GetUserResponse>(res, {
|
||||
data: {
|
||||
email: user[0].email,
|
||||
twoFactorEnabled: user[0].twoFactorEnabled,
|
||||
emailVerified: user[0].emailVerified
|
||||
emailVerified: user[0].emailVerified,
|
||||
},
|
||||
success: true,
|
||||
error: false,
|
||||
@@ -45,6 +57,11 @@ export async function getUser(req: Request, res: Response, next: NextFunction):
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
return next(createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred..."));
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.INTERNAL_SERVER_ERROR,
|
||||
"An error occurred...",
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user