mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-16 14:25:22 +00:00
Use origin from header for baseUrl of emails (instead of AUTH_URL). Also removed reference to hide scrollbars
This commit is contained in:
parent
484aea8406
commit
7d0540de13
5 changed files with 12 additions and 45 deletions
|
|
@ -710,7 +710,7 @@ export const createInvites = async (emails: string[], domain: string): Promise<{
|
||||||
const inviteLink = `${origin}/redeem?invite_id=${invite.id}`;
|
const inviteLink = `${origin}/redeem?invite_id=${invite.id}`;
|
||||||
const transport = createTransport(env.SMTP_CONNECTION_URL);
|
const transport = createTransport(env.SMTP_CONNECTION_URL);
|
||||||
const html = await render(InviteUserEmail({
|
const html = await render(InviteUserEmail({
|
||||||
baseUrl: env.AUTH_URL,
|
baseUrl: origin,
|
||||||
host: {
|
host: {
|
||||||
name: session.user.name ?? undefined,
|
name: session.user.name ?? undefined,
|
||||||
email: session.user.email!,
|
email: session.user.email!,
|
||||||
|
|
@ -1109,7 +1109,7 @@ export const createStripeCheckoutSession = async (domain: string) => sew(() =>
|
||||||
});
|
});
|
||||||
const numOrgMembers = orgMembers.length;
|
const numOrgMembers = orgMembers.length;
|
||||||
|
|
||||||
const origin = (await headers()).get('origin')
|
const origin = (await headers()).get('origin')!;
|
||||||
const prices = await stripeClient.prices.list({
|
const prices = await stripeClient.prices.list({
|
||||||
product: env.STRIPE_PRODUCT_ID,
|
product: env.STRIPE_PRODUCT_ID,
|
||||||
expand: ['data.product'],
|
expand: ['data.product'],
|
||||||
|
|
@ -1161,7 +1161,7 @@ export const getCustomerPortalSessionLink = async (domain: string): Promise<stri
|
||||||
return stripeClientNotInitialized();
|
return stripeClientNotInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
const origin = (await headers()).get('origin')
|
const origin = (await headers()).get('origin')!;
|
||||||
const portalSession = await stripeClient.billingPortal.sessions.create({
|
const portalSession = await stripeClient.billingPortal.sessions.create({
|
||||||
customer: org.stripeCustomerId as string,
|
customer: org.stripeCustomerId as string,
|
||||||
return_url: `${origin}/${domain}/settings/billing`,
|
return_url: `${origin}/${domain}/settings/billing`,
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ export const SearchBar = ({
|
||||||
/>
|
/>
|
||||||
<CodeMirror
|
<CodeMirror
|
||||||
ref={editorRef}
|
ref={editorRef}
|
||||||
className="overflow-x-auto scrollbar-hide w-full"
|
className="overflow-x-auto w-full"
|
||||||
placeholder={isHistorySearchEnabled ? "Filter history..." : "Search (/) through repos..."}
|
placeholder={isHistorySearchEnabled ? "Filter history..." : "Search (/) through repos..."}
|
||||||
value={query}
|
value={query}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ export default async function Login({ searchParams }: LoginProps) {
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col min-h-screen">
|
<div className="flex flex-col min-h-screen bg-backgroundSecondary">
|
||||||
<div className="flex-1 flex flex-col items-center p-4 sm:p-12 w-full bg-backgroundSecondary">
|
<div className="flex-1 flex flex-col items-center p-4 sm:p-12 w-full">
|
||||||
<LoginForm
|
<LoginForm
|
||||||
callbackUrl={searchParams.callbackUrl}
|
callbackUrl={searchParams.callbackUrl}
|
||||||
error={searchParams.error}
|
error={searchParams.error}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import { createTransport } from 'nodemailer';
|
||||||
import { render } from '@react-email/render';
|
import { render } from '@react-email/render';
|
||||||
import MagicLinkEmail from './emails/magicLinkEmail';
|
import MagicLinkEmail from './emails/magicLinkEmail';
|
||||||
import { SINGLE_TENANT_ORG_ID } from './lib/constants';
|
import { SINGLE_TENANT_ORG_ID } from './lib/constants';
|
||||||
import bcrypt from 'bcrypt';
|
import bcrypt from 'bcryptjs';
|
||||||
|
|
||||||
export const runtime = 'nodejs';
|
export const runtime = 'nodejs';
|
||||||
|
|
||||||
|
|
@ -59,9 +59,10 @@ export const getProviders = () => {
|
||||||
const token = String(Math.floor(100000 + Math.random() * 900000));
|
const token = String(Math.floor(100000 + Math.random() * 900000));
|
||||||
return token;
|
return token;
|
||||||
},
|
},
|
||||||
sendVerificationRequest: async ({ identifier, provider, token }) => {
|
sendVerificationRequest: async ({ identifier, provider, token, request }) => {
|
||||||
|
const origin = request.headers.get('origin')!;
|
||||||
const transport = createTransport(provider.server);
|
const transport = createTransport(provider.server);
|
||||||
const html = await render(MagicLinkEmail({ baseUrl: env.AUTH_URL, token: token }));
|
const html = await render(MagicLinkEmail({ baseUrl: origin, token: token }));
|
||||||
const result = await transport.sendMail({
|
const result = await transport.sendMail({
|
||||||
to: identifier,
|
to: identifier,
|
||||||
from: provider.from,
|
from: provider.from,
|
||||||
|
|
@ -179,9 +180,6 @@ const onCreateUser = async ({ user }: { user: AuthJsUser }) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const useSecureCookies = env.AUTH_URL?.startsWith("https://") ?? false;
|
|
||||||
const hostName = env.AUTH_URL ? new URL(env.AUTH_URL).hostname : "localhost";
|
|
||||||
|
|
||||||
export const { handlers, signIn, signOut, auth } = NextAuth({
|
export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||||
secret: env.AUTH_SECRET,
|
secret: env.AUTH_SECRET,
|
||||||
adapter: PrismaAdapter(prisma),
|
adapter: PrismaAdapter(prisma),
|
||||||
|
|
@ -213,37 +211,6 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||||
return session;
|
return session;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
cookies: {
|
|
||||||
sessionToken: {
|
|
||||||
name: `${useSecureCookies ? '__Secure-' : ''}authjs.session-token`,
|
|
||||||
options: {
|
|
||||||
httpOnly: true,
|
|
||||||
sameSite: 'lax',
|
|
||||||
path: '/',
|
|
||||||
secure: useSecureCookies,
|
|
||||||
domain: `.${hostName}`
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callbackUrl: {
|
|
||||||
name: `${useSecureCookies ? '__Secure-' : ''}authjs.callback-url`,
|
|
||||||
options: {
|
|
||||||
sameSite: 'lax',
|
|
||||||
path: '/',
|
|
||||||
secure: useSecureCookies,
|
|
||||||
domain: `.${hostName}`
|
|
||||||
}
|
|
||||||
},
|
|
||||||
csrfToken: {
|
|
||||||
name: `${useSecureCookies ? '__Secure-' : ''}authjs.csrf-token`,
|
|
||||||
options: {
|
|
||||||
httpOnly: true,
|
|
||||||
sameSite: 'lax',
|
|
||||||
path: '/',
|
|
||||||
secure: useSecureCookies,
|
|
||||||
domain: `.${hostName}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
providers: getProviders(),
|
providers: getProviders(),
|
||||||
pages: {
|
pages: {
|
||||||
signIn: "/login",
|
signIn: "/login",
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,6 @@ export async function middleware(request: NextRequest) {
|
||||||
export const config = {
|
export const config = {
|
||||||
// https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher
|
// https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher
|
||||||
matcher: [
|
matcher: [
|
||||||
'/((?!api|_next/static|ingest|_next/image|favicon.ico|sitemap.xml|robots.txt).*)'
|
'/((?!api|_next/static|ingest|_next/image|favicon.ico|sitemap.xml|robots.txt|sb_logo_light_large.png|arrow.png|placeholder_avatar.png).*)',
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue