Merge pull request #377 from gitroomhq/feat/fix-teams
hotfix: fixed team invite
This commit is contained in:
commit
c4326f1c8a
|
|
@ -38,7 +38,7 @@ export const SettingsPopup: FC<{ getRef?: Ref<any> }> = (props) => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const url = useSearchParams();
|
const url = useSearchParams();
|
||||||
const showLogout = !url.get('onboarding');
|
const showLogout = !url.get('onboarding') || user?.tier?.current === "FREE";
|
||||||
|
|
||||||
const loadProfile = useCallback(async () => {
|
const loadProfile = useCallback(async () => {
|
||||||
const personal = await (await fetch('/user/personal')).json();
|
const personal = await (await fetch('/user/personal')).json();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { NextResponse } from 'next/server';
|
import { NextResponse } from 'next/server';
|
||||||
import type { NextRequest } from 'next/server';
|
import type { NextRequest } from 'next/server';
|
||||||
import { fetchBackend } from '@gitroom/helpers/utils/custom.fetch.func';
|
|
||||||
import { getCookieUrlFromDomain } from '@gitroom/helpers/subdomain/subdomain.management';
|
import { getCookieUrlFromDomain } from '@gitroom/helpers/subdomain/subdomain.management';
|
||||||
|
import { internalFetch } from '@gitroom/helpers/utils/internal.fetch';
|
||||||
|
|
||||||
// This function can be marked `async` if using `await` inside
|
// This function can be marked `async` if using `await` inside
|
||||||
export async function middleware(request: NextRequest) {
|
export async function middleware(request: NextRequest) {
|
||||||
|
|
@ -68,13 +68,10 @@ export async function middleware(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
if (org) {
|
if (org) {
|
||||||
const { id } = await (
|
const { id } = await (
|
||||||
await fetchBackend('/user/join-org', {
|
await internalFetch('/user/join-org', {
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
org,
|
org,
|
||||||
}),
|
}),
|
||||||
headers: {
|
|
||||||
auth: authCookie?.value!,
|
|
||||||
},
|
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
})
|
})
|
||||||
).json();
|
).json();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { loadVars } from '@gitroom/react/helpers/variable.context';
|
|
||||||
|
|
||||||
export interface Params {
|
export interface Params {
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
|
|
@ -48,6 +47,6 @@ export const customFetch = (
|
||||||
|
|
||||||
export const fetchBackend = customFetch({
|
export const fetchBackend = customFetch({
|
||||||
get baseUrl() {
|
get baseUrl() {
|
||||||
return loadVars().backendUrl;
|
return process.env.BACKEND_URL!;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ export class OrganizationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async inviteTeamMember(orgId: string, body: AddTeamMemberDto) {
|
async inviteTeamMember(orgId: string, body: AddTeamMemberDto) {
|
||||||
const timeLimit = dayjs().add(15, 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
const timeLimit = dayjs().add(1, 'hour').format('YYYY-MM-DD HH:mm:ss');
|
||||||
const id = makeId(5);
|
const id = makeId(5);
|
||||||
const url =
|
const url =
|
||||||
process.env.FRONTEND_URL +
|
process.env.FRONTEND_URL +
|
||||||
|
|
@ -55,7 +55,7 @@ export class OrganizationService {
|
||||||
await this._notificationsService.sendEmail(
|
await this._notificationsService.sendEmail(
|
||||||
body.email,
|
body.email,
|
||||||
'You have been invited to join an organization',
|
'You have been invited to join an organization',
|
||||||
`You have been invited to join an organization. Click <a href="${url}">here</a> to join.<br />The link will expire in 15 minutes.`
|
`You have been invited to join an organization. Click <a href="${url}">here</a> to join.<br />The link will expire in 1 hour.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return { url };
|
return { url };
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue