mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
fix: api keys not showing (#1839)
This commit is contained in:
@ -83,7 +83,9 @@ export const OrganisationCreateDialog = ({ trigger, ...props }: OrganisationCrea
|
|||||||
|
|
||||||
const { mutateAsync: createOrganisation } = trpc.organisation.create.useMutation();
|
const { mutateAsync: createOrganisation } = trpc.organisation.create.useMutation();
|
||||||
|
|
||||||
const { data: plansData } = trpc.billing.plans.get.useQuery();
|
const { data: plansData } = trpc.billing.plans.get.useQuery(undefined, {
|
||||||
|
enabled: IS_BILLING_ENABLED(),
|
||||||
|
});
|
||||||
|
|
||||||
const onFormSubmit = async ({ name }: TCreateOrganisationFormSchema) => {
|
const onFormSubmit = async ({ name }: TCreateOrganisationFormSchema) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -1,15 +0,0 @@
|
|||||||
import { prisma } from '@documenso/prisma';
|
|
||||||
|
|
||||||
export type GetApiTokenByIdOptions = {
|
|
||||||
id: number;
|
|
||||||
userId: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getApiTokenById = async ({ id, userId }: GetApiTokenByIdOptions) => {
|
|
||||||
return await prisma.apiToken.findFirstOrThrow({
|
|
||||||
where: {
|
|
||||||
id,
|
|
||||||
userId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@ -11,7 +11,6 @@ export type GetApiTokensOptions = {
|
|||||||
export const getApiTokens = async ({ userId, teamId }: GetApiTokensOptions) => {
|
export const getApiTokens = async ({ userId, teamId }: GetApiTokensOptions) => {
|
||||||
return await prisma.apiToken.findMany({
|
return await prisma.apiToken.findMany({
|
||||||
where: {
|
where: {
|
||||||
userId,
|
|
||||||
team: buildTeamWhereQuery({
|
team: buildTeamWhereQuery({
|
||||||
teamId,
|
teamId,
|
||||||
userId,
|
userId,
|
||||||
|
|||||||
@ -1,31 +1,15 @@
|
|||||||
import { createApiToken } from '@documenso/lib/server-only/public-api/create-api-token';
|
import { createApiToken } from '@documenso/lib/server-only/public-api/create-api-token';
|
||||||
import { deleteTokenById } from '@documenso/lib/server-only/public-api/delete-api-token-by-id';
|
import { deleteTokenById } from '@documenso/lib/server-only/public-api/delete-api-token-by-id';
|
||||||
import { getApiTokenById } from '@documenso/lib/server-only/public-api/get-api-token-by-id';
|
|
||||||
import { getApiTokens } from '@documenso/lib/server-only/public-api/get-api-tokens';
|
import { getApiTokens } from '@documenso/lib/server-only/public-api/get-api-tokens';
|
||||||
|
|
||||||
import { authenticatedProcedure, router } from '../trpc';
|
import { authenticatedProcedure, router } from '../trpc';
|
||||||
import {
|
import { ZCreateTokenMutationSchema, ZDeleteTokenByIdMutationSchema } from './schema';
|
||||||
ZCreateTokenMutationSchema,
|
|
||||||
ZDeleteTokenByIdMutationSchema,
|
|
||||||
ZGetApiTokenByIdQuerySchema,
|
|
||||||
} from './schema';
|
|
||||||
|
|
||||||
export const apiTokenRouter = router({
|
export const apiTokenRouter = router({
|
||||||
getTokens: authenticatedProcedure.query(async ({ ctx }) => {
|
getTokens: authenticatedProcedure.query(async ({ ctx }) => {
|
||||||
return await getApiTokens({ userId: ctx.user.id, teamId: ctx.teamId });
|
return await getApiTokens({ userId: ctx.user.id, teamId: ctx.teamId });
|
||||||
}),
|
}),
|
||||||
|
|
||||||
getTokenById: authenticatedProcedure
|
|
||||||
.input(ZGetApiTokenByIdQuerySchema)
|
|
||||||
.query(async ({ input, ctx }) => {
|
|
||||||
const { id } = input;
|
|
||||||
|
|
||||||
return await getApiTokenById({
|
|
||||||
id,
|
|
||||||
userId: ctx.user.id,
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
|
|
||||||
createToken: authenticatedProcedure
|
createToken: authenticatedProcedure
|
||||||
.input(ZCreateTokenMutationSchema)
|
.input(ZCreateTokenMutationSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -1,11 +1,5 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
export const ZGetApiTokenByIdQuerySchema = z.object({
|
|
||||||
id: z.number().min(1),
|
|
||||||
});
|
|
||||||
|
|
||||||
export type TGetApiTokenByIdQuerySchema = z.infer<typeof ZGetApiTokenByIdQuerySchema>;
|
|
||||||
|
|
||||||
export const ZCreateTokenMutationSchema = z.object({
|
export const ZCreateTokenMutationSchema = z.object({
|
||||||
teamId: z.number(),
|
teamId: z.number(),
|
||||||
tokenName: z.string().min(3, { message: 'The token name should be 3 characters or longer' }),
|
tokenName: z.string().min(3, { message: 'The token name should be 3 characters or longer' }),
|
||||||
|
|||||||
Reference in New Issue
Block a user