Skip to content

Commit

Permalink
Merge pull request #127 from blinko-space/fix-api-auth
Browse files Browse the repository at this point in the history
fix: api auth issue
  • Loading branch information
blinko-space authored Nov 18, 2024
2 parents 8dba3d0 + 147fd42 commit b225033
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/pages/resources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { showTipsDialog } from "@/components/Common/TipsDialog";
import { useTranslation } from "react-i18next";
import { PromiseCall } from "@/store/standard/PromiseState";
import { DialogStore } from "@/store/module/Dialog";
import { FilesAttachmentRender } from "@/components/Common/AttachmentRender";

const Page = observer(() => {
const blinko = RootStore.Get(BlinkoStore)
Expand All @@ -28,15 +29,16 @@ const Page = observer(() => {
blinko.resourceList.value?.map(i => {
const extension = helper.getFileExtension(i.path)
return <Card shadow="none" className="group bg-background cursor-pointer px-4 pt-4 mb-4 pb-2 flex flex-col gap-2 items-center">
{
{/* {
helper.getFileType(i.path) == 'image' ?
<PhotoView width={150} src={i.path} >
<Image radius="sm" className="w-full" src={i.path} alt='' />
</PhotoView> :
<div className="w-[60px] ">
<FileIcon extension={extension} {...defaultStyles[extension ?? '']} />
</div>
}
} */}
<FilesAttachmentRender files={[i]} preview columns={1}/>
<div className="w-full break-words whitespace-normal text-xs font-bold">{decodeURIComponent(i.name)}</div>
<div className="w-full break-words whitespace-normal text-xs text-desc flex">
<div>{dayjs(i.createdAt).fromNow()}</div>
Expand Down
2 changes: 1 addition & 1 deletion src/server/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type User = {
export async function createContext(
opts: trpcNext.CreateNextContextOptions,
) {
const token = await getToken({ req: opts.req, secret: process.env.NEXTAUTH_SECRE }) as User ;
const token = await getToken({ req: opts.req, secret: process.env.NEXTAUTH_SECRE }) as User;
if (!token?.sub) {
return {} as User;
}
Expand Down
3 changes: 2 additions & 1 deletion src/server/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const t = initTRPC.context<Context>().meta<OpenApiMeta>().create({
export const router = t.router;
export const publicProcedure = t.procedure;
export const authProcedure = t.procedure.use(async ({ ctx, next }) => {
if (!ctx?.id) {
console.log(ctx)
if (!ctx?.name) {
throw new TRPCError({
code: "UNAUTHORIZED",
message: 'Unauthorized'
Expand Down

0 comments on commit b225033

Please sign in to comment.