mirror of
https://github.com/documenso/documenso.git
synced 2025-11-22 12:41:36 +10:00
fix: wip
This commit is contained in:
@ -19,7 +19,7 @@
|
||||
"@documenso/prisma": "*",
|
||||
"@ts-rest/core": "^3.30.5",
|
||||
"@ts-rest/open-api": "^3.33.0",
|
||||
"@ts-rest/serverless": "^3.51.0",
|
||||
"@ts-rest/serverless": "^3.30.5",
|
||||
"@types/swagger-ui-react": "^4.18.3",
|
||||
"luxon": "^3.4.0",
|
||||
"superjson": "^1.13.1",
|
||||
|
||||
@ -8,6 +8,7 @@ import type { AuthAppType } from '../server';
|
||||
import { handleSignInRedirect } from '../server/lib/utils/redirect';
|
||||
import type {
|
||||
TForgotPasswordSchema,
|
||||
TResendVerifyEmailSchema,
|
||||
TResetPasswordSchema,
|
||||
TSignUpSchema,
|
||||
TUpdatePasswordSchema,
|
||||
@ -79,6 +80,13 @@ export class AuthClient {
|
||||
await this.handleError(response);
|
||||
},
|
||||
|
||||
resendVerifyEmail: async (data: TResendVerifyEmailSchema) => {
|
||||
const response = await this.client['email-password']['resend-verify-email'].$post({
|
||||
json: data,
|
||||
});
|
||||
await this.handleError(response);
|
||||
},
|
||||
|
||||
verifyEmail: async (data: TVerifyEmailSchema) => {
|
||||
const response = await this.client['email-password']['verify-email'].$post({ json: data });
|
||||
await this.handleError(response);
|
||||
|
||||
@ -30,6 +30,7 @@ import { getRequiredSession, getSession } from '../lib/utils/get-session';
|
||||
import type { HonoAuthContext } from '../types/context';
|
||||
import {
|
||||
ZForgotPasswordSchema,
|
||||
ZResendVerifyEmailSchema,
|
||||
ZResetPasswordSchema,
|
||||
ZSignInSchema,
|
||||
ZSignUpSchema,
|
||||
@ -196,17 +197,17 @@ export const emailPasswordRoute = new Hono<HonoAuthContext>()
|
||||
/**
|
||||
* Resend verification email endpoint.
|
||||
*/
|
||||
.post('/resend-email', zValidator('json', ZVerifyEmailSchema), async (c) => {
|
||||
const { state, userId } = await verifyEmail({ token: c.req.valid('json').token });
|
||||
.post('/resend-verify-email', zValidator('json', ZResendVerifyEmailSchema), async (c) => {
|
||||
const { email } = c.req.valid('json');
|
||||
|
||||
// If email is verified, automatically authenticate user.
|
||||
if (state === EMAIL_VERIFICATION_STATE.VERIFIED && userId !== null) {
|
||||
await onAuthorize({ userId }, c);
|
||||
}
|
||||
|
||||
return c.json({
|
||||
state,
|
||||
await jobsClient.triggerJob({
|
||||
name: 'send.signup.confirmation.email',
|
||||
payload: {
|
||||
email,
|
||||
},
|
||||
});
|
||||
|
||||
return c.text('OK', 201);
|
||||
})
|
||||
/**
|
||||
* Forgot password endpoint.
|
||||
|
||||
@ -68,6 +68,12 @@ export const ZVerifyEmailSchema = z.object({
|
||||
|
||||
export type TVerifyEmailSchema = z.infer<typeof ZVerifyEmailSchema>;
|
||||
|
||||
export const ZResendVerifyEmailSchema = z.object({
|
||||
email: z.string().email().min(1),
|
||||
});
|
||||
|
||||
export type TResendVerifyEmailSchema = z.infer<typeof ZResendVerifyEmailSchema>;
|
||||
|
||||
export const ZUpdatePasswordSchema = z.object({
|
||||
currentPassword: ZCurrentPasswordSchema,
|
||||
password: ZPasswordSchema,
|
||||
|
||||
@ -2,8 +2,8 @@ import type { Transporter } from 'nodemailer';
|
||||
import { createTransport } from 'nodemailer';
|
||||
|
||||
import { env } from '@documenso/lib/utils/env';
|
||||
import { ResendTransport } from '@documenso/nodemailer-resend';
|
||||
|
||||
// import { ResendTransport } from '@documenso/nodemailer-resend';
|
||||
import { MailChannelsTransport } from './transports/mailchannels';
|
||||
|
||||
/**
|
||||
@ -63,14 +63,13 @@ const getTransport = (): Transporter => {
|
||||
);
|
||||
}
|
||||
|
||||
// Todo
|
||||
// if (transport === 'resend') {
|
||||
// return createTransport(
|
||||
// ResendTransport.makeTransport({
|
||||
// apiKey: env('NEXT_PRIVATE_RESEND_API_KEY') || '',
|
||||
// }),
|
||||
// );
|
||||
// }
|
||||
if (transport === 'resend') {
|
||||
return createTransport(
|
||||
ResendTransport.makeTransport({
|
||||
apiKey: env('NEXT_PRIVATE_RESEND_API_KEY') || '',
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
if (transport === 'smtp-api') {
|
||||
if (!env('NEXT_PRIVATE_SMTP_HOST') || !env('NEXT_PRIVATE_SMTP_APIKEY')) {
|
||||
|
||||
@ -35,11 +35,9 @@
|
||||
"@react-email/section": "0.0.10",
|
||||
"@react-email/tailwind": "0.0.9",
|
||||
"@react-email/text": "0.0.6",
|
||||
"@lingui/macro": "^5.2.0",
|
||||
"@lingui/react": "^5.2.0",
|
||||
"nodemailer": "^6.9.9",
|
||||
"react-email": "^1.9.5",
|
||||
"resend": "^2.0.0"
|
||||
"nodemailer": "6.9.9",
|
||||
"react-email": "1.9.5",
|
||||
"resend": "2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@documenso/tailwind-config": "*",
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import * as ReactEmail from '@react-email/render';
|
||||
|
||||
import config from '@documenso/tailwind-config';
|
||||
|
||||
import { Tailwind } from './components';
|
||||
import { BrandingProvider, type BrandingSettings } from './providers/branding';
|
||||
|
||||
// Todo:
|
||||
// import config from '@documenso/tailwind-config';
|
||||
|
||||
export type RenderOptions = ReactEmail.Options & {
|
||||
branding?: BrandingSettings;
|
||||
};
|
||||
@ -18,7 +17,7 @@ export const render = (element: React.ReactNode, options?: RenderOptions) => {
|
||||
config={{
|
||||
theme: {
|
||||
extend: {
|
||||
// colors: config.theme.extend.colors,
|
||||
colors: config.theme.extend.colors,
|
||||
},
|
||||
},
|
||||
}}
|
||||
@ -37,7 +36,7 @@ export const renderAsync = async (element: React.ReactNode, options?: RenderOpti
|
||||
config={{
|
||||
theme: {
|
||||
extend: {
|
||||
// colors: config.theme.extend.colors,
|
||||
colors: config.theme.extend.colors,
|
||||
},
|
||||
},
|
||||
}}
|
||||
|
||||
@ -14,7 +14,7 @@ type SupportedLanguages = (typeof SUPPORTED_LANGUAGE_CODES)[number];
|
||||
export async function loadCatalog(lang: SupportedLanguages): Promise<{
|
||||
[k: string]: Messages;
|
||||
}> {
|
||||
const extension = env('NODE_ENV') === 'development' ? 'po' : 'js';
|
||||
const extension = env('NODE_ENV') === 'development' ? 'po' : 'mjs';
|
||||
|
||||
const { messages } = await import(`../../translations/${lang}/web.${extension}`);
|
||||
|
||||
|
||||
1
packages/lib/translations/.gitignore
vendored
1
packages/lib/translations/.gitignore
vendored
@ -2,3 +2,4 @@
|
||||
|
||||
# Compiled translations.
|
||||
*.js
|
||||
*.mjs
|
||||
|
||||
@ -1,18 +1,21 @@
|
||||
/// <reference types="@documenso/tsconfig/process-env.d.ts" />
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__ENV__?: Record<string, string | undefined>;
|
||||
}
|
||||
}
|
||||
|
||||
type EnvironmentVariable = keyof NodeJS.ProcessEnv;
|
||||
|
||||
export const env = (variable: EnvironmentVariable | (string & object)): string | undefined => {
|
||||
// console.log({
|
||||
// ['typeof window']: typeof window,
|
||||
// ['process.env']: process.env,
|
||||
// ['window.__ENV__']: typeof window !== 'undefined' && window.__ENV__,
|
||||
// });
|
||||
|
||||
// This may need ot be import.meta.env.SSR depending on vite.
|
||||
if (typeof window !== 'undefined' && typeof window.__ENV__ === 'object') {
|
||||
return window.__ENV__[variable];
|
||||
}
|
||||
|
||||
return process.env[variable];
|
||||
return process?.env?.[variable];
|
||||
};
|
||||
|
||||
// Todo: Test
|
||||
export const createPublicEnv = () =>
|
||||
Object.fromEntries(Object.entries(process.env).filter(([key]) => key.startsWith('NEXT_PUBLIC_')));
|
||||
|
||||
@ -3,13 +3,11 @@ import { i18n } from '@lingui/core';
|
||||
|
||||
import type { I18nLocaleData, SupportedLanguageCodes } from '../constants/i18n';
|
||||
import { APP_I18N_OPTIONS } from '../constants/i18n';
|
||||
import { env } from './env';
|
||||
|
||||
export async function dynamicActivate(locale: string) {
|
||||
// const extension = import.meta.env.PROD env('NODE_ENV') === 'development' ? 'po' : 'js';
|
||||
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||
const extension = import.meta.env.PROD ? 'js' : 'po';
|
||||
const extension = env('NODE_ENV') === 'development' ? 'po' : 'mjs';
|
||||
|
||||
// Todo: Use extension (currently breaks).
|
||||
const { messages } = await import(`../translations/${locale}/web.${extension}`);
|
||||
|
||||
i18n.loadAndActivate({ locale, messages });
|
||||
|
||||
Reference in New Issue
Block a user