Merge branch 'main' of https://github.com/marcopedone/infoalloggi-monorepo
This commit is contained in:
commit
d35951657a
2 changed files with 26 additions and 36 deletions
|
|
@ -152,7 +152,7 @@ export const logIn = async ({
|
|||
const accessToken = await signToken(payload, "1h", "accessToken");
|
||||
const refreshToken = await signToken(payload, "1d", "refreshToken");
|
||||
|
||||
// Send Access Token in Cookie
|
||||
try {
|
||||
await setCookie(ACCESS_TOKEN_COOKIE_NAME, accessToken, {
|
||||
...accessTokenCookieOptions,
|
||||
req,
|
||||
|
|
@ -164,27 +164,17 @@ export const logIn = async ({
|
|||
res,
|
||||
});
|
||||
|
||||
const cookies = await getCookies({ req, res });
|
||||
if (!cookies) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: "Errore durante il login, cookies non impostati",
|
||||
});
|
||||
}
|
||||
if (!cookies[ACCESS_TOKEN_COOKIE_NAME]) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: "Errore durante il login, access token non impostato",
|
||||
});
|
||||
}
|
||||
if (!cookies[REFRESH_TOKEN_COOKIE_NAME]) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: "Errore durante il login, refresh token non impostato",
|
||||
});
|
||||
}
|
||||
return { status: "success" as const };
|
||||
} catch (cookieError) {
|
||||
console.error("Error setting cookies:", cookieError);
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: `Errore durante l'impostazione dei cookies: ${(cookieError as Error).message}`,
|
||||
});
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error("Login error:", e);
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: `Errore login: ${(e as Error).message}`,
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ import type PublicSchema from "~/schemas/public/PublicSchema";
|
|||
* The database connection pool.
|
||||
*/
|
||||
const pool = new Pool({
|
||||
connectionTimeoutMillis: 2000,
|
||||
//connectionTimeoutMillis: 2000,
|
||||
database: env.POSTGRES_DB,
|
||||
host: env.PGHOST,
|
||||
idleTimeoutMillis: 30000,
|
||||
//idleTimeoutMillis: 30000,
|
||||
max: 10,
|
||||
password: env.POSTGRES_PASSWORD,
|
||||
port: Number.parseInt(env.PGPORT),
|
||||
|
|
@ -39,8 +39,8 @@ export const db = new Kysely<Database>({
|
|||
pool: pool,
|
||||
}),
|
||||
|
||||
log: (_event) => {
|
||||
//DbLogger(event);
|
||||
log: (event) => {
|
||||
DbLogger(event);
|
||||
},
|
||||
|
||||
//plugins: [new SerializePlugin()]
|
||||
|
|
@ -53,7 +53,7 @@ export const db = new Kysely<Database>({
|
|||
],
|
||||
});
|
||||
|
||||
const _DbLogger = (event: LogEvent) => {
|
||||
const DbLogger = (event: LogEvent) => {
|
||||
if (event.level === "query") {
|
||||
console.log("\x1b[33mquery:\x1b[0m", event.query.sql);
|
||||
console.log("\x1b[36mparams:\x1b[0m", event.query.parameters);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue