feat: dashboard v2, esm, upgrades (#211)

* esm

* wip

* wip

* wip

* wip

* wip

* wip

* subscription notice

* wip

* wip

* wip

* fix envs

* fix: update docker build

* fix

* esm/types

* delete dashboard :D

* add patches to dockerfiles

* update packages + catalogs + ts

* wip

* remove native libs

* ts

* improvements

* fix redirects and fetching session

* try fix favicon

* fixes

* fix

* order and resize reportds within a dashboard

* improvements

* wip

* added userjot to dashboard

* fix

* add op

* wip

* different cache key

* improve date picker

* fix table

* event details loading

* redo onboarding completely

* fix login

* fix

* fix

* extend session, billing and improve bars

* fix

* reduce price on 10M
This commit is contained in:
Carl-Gerhard Lindesvärd
2025-10-16 12:27:44 +02:00
committed by GitHub
parent 436e81ecc9
commit 81a7e5d62e
741 changed files with 32695 additions and 16996 deletions

View File

@@ -9,6 +9,7 @@ import {
hashPassword,
invalidateSession,
setSessionTokenCookie,
validateSessionToken,
verifyPasswordHash,
} from '@openpanel/auth';
import { generateSecureId } from '@openpanel/common/server/id';
@@ -26,7 +27,6 @@ import {
zSignInShare,
zSignUpEmail,
} from '@openpanel/validation';
import * as bcrypt from 'bcrypt';
import { z } from 'zod';
import { TRPCAccessError, TRPCNotFoundError } from '../errors';
import {
@@ -216,21 +216,17 @@ export const authRouter = createTRPCRouter({
throw TRPCAccessError('Incorrect email or password');
}
} else {
const validPassword = await bcrypt.compare(
password,
user.account.password ?? '',
throw TRPCAccessError(
'Reset your password, old password has expired',
);
if (!validPassword) {
throw TRPCAccessError('Incorrect email or password');
}
}
}
const token = generateSessionToken();
const session = await createSession(token, user.id);
console.log('session', session);
setSessionTokenCookie(ctx.setCookie, token, session.expiresAt);
console.log('ctx.setCookie', ctx.setCookie);
return {
type: 'email',
};
@@ -318,7 +314,7 @@ export const authRouter = createTRPCRouter({
await sendEmail('reset-password', {
to: input.email,
data: {
url: `${process.env.NEXT_PUBLIC_DASHBOARD_URL}/reset-password?token=${token}`,
url: `${process.env.DASHBOARD_URL || process.env.NEXT_PUBLIC_DASHBOARD_URL}/reset-password?token=${token}`,
},
});
@@ -328,6 +324,26 @@ export const authRouter = createTRPCRouter({
return ctx.session;
}),
extendSession: publicProcedure.mutation(async ({ ctx }) => {
if (!ctx.session.session || !ctx.cookies.session) {
return { extended: false };
}
const token = ctx.cookies.session;
const session = await validateSessionToken(token);
if (session.session) {
// Re-set the cookie with updated expiration
setSessionTokenCookie(ctx.setCookie, token, session.session.expiresAt);
return {
extended: true,
expiresAt: session.session.expiresAt,
};
}
return { extended: false };
}),
signInShare: publicProcedure
.use(
rateLimitMiddleware({