arete
arete
TTCTheo's Typesafe Cult
Created by arete on 5/28/2024 in #questions
react packages similar to jira tempo timesheets
No description
4 replies
TTCTheo's Typesafe Cult
Created by arete on 4/30/2024 in #questions
package lib to preview pdf or docx
No description
2 replies
TTCTheo's Typesafe Cult
Created by arete on 11/16/2023 in #questions
call db directly in next js app router
No description
18 replies
TTCTheo's Typesafe Cult
Created by arete on 10/7/2023 in #questions
app router cost
is it true that app router will be much more cheaper, cause i just watch theos video and i want to hear a lil bit more of it, thankss yall
7 replies
TTCTheo's Typesafe Cult
Created by arete on 9/1/2023 in #questions
Batching pros and cons
httpBatchLink and httpLink is different in term of performance or is the same Thanks!
2 replies
TTCTheo's Typesafe Cult
Created by arete on 8/22/2023 in #questions
trpc context with clerk
hello guys im very new on clerk, and was wondering why the user return on trpc middleware still not return 401 any idea?
2 replies
TTCTheo's Typesafe Cult
Created by arete on 8/21/2023 in #questions
clerk user undefined
No description
3 replies
TTCTheo's Typesafe Cult
Created by arete on 8/15/2023 in #questions
clerk metadata
hello guys i never use clerk before and still using nextauth, the reason is if we use nextauth db strategy and i change something in user session while the user is still online, lets say i change the role directly in db, the user session automaticly change. if we using jwt strategy the user need to logout first and got the new session. in clerk i see people using the metada to insert their role, and we can update it, the question is what if the user is online using our app, and we want to update their metadata to differnt role, do we need to make the user logout first or it will automaticlly change, if yes im gladly migrate to Clerk😁 Thanks!
12 replies
TTCTheo's Typesafe Cult
Created by arete on 8/15/2023 in #questions
shadcn ui table
No description
30 replies
TTCTheo's Typesafe Cult
Created by arete on 7/26/2023 in #questions
how to make base url change based on environment
2 replies
TTCTheo's Typesafe Cult
Created by arete on 6/23/2023 in #questions
cant register a new user with next auth prisma
1 replies
TTCTheo's Typesafe Cult
Created by arete on 6/1/2023 in #questions
is this middleware is good for longterm?
hello guys, in these code snippet i want to check if user is subs and valid, but i im wondering if this thing is good to do for long term, and what is the pros and cons of this thankss
const enforceUserIsSubscribed = t.middleware(async ({ ctx, next }) => {
if (!ctx.session || !ctx.session.user) {
throw new TRPCError({ code: "UNAUTHORIZED" });
}
if (!ctx.session.user.isSubscribed || ctx.session.user.role !== "admin") {
throw new TRPCError({ code: "UNAUTHORIZED" });
}
// user is subscribed, check if subscription is still valid
const currentDateTime = new Date();
const userSubscriptions = await ctx.prisma.subscription.findMany({
where: {
subscriberId: ctx.session.user.id,
subscribedUntil: {
gte: currentDateTime,
},
},
});
if (!userSubscriptions || userSubscriptions.length === 0) {
//set user to not subscribed
await ctx.prisma.user.update({
where: {
id: ctx.session.user.id,
},
data: {
isSubscribed: false,
},
});
throw new TRPCError({ code: "UNAUTHORIZED" });
}
return next({
ctx: {
// infers the `session` as non-nullable
session: { ...ctx.session, user: ctx.session.user },
},
});
});
const enforceUserIsSubscribed = t.middleware(async ({ ctx, next }) => {
if (!ctx.session || !ctx.session.user) {
throw new TRPCError({ code: "UNAUTHORIZED" });
}
if (!ctx.session.user.isSubscribed || ctx.session.user.role !== "admin") {
throw new TRPCError({ code: "UNAUTHORIZED" });
}
// user is subscribed, check if subscription is still valid
const currentDateTime = new Date();
const userSubscriptions = await ctx.prisma.subscription.findMany({
where: {
subscriberId: ctx.session.user.id,
subscribedUntil: {
gte: currentDateTime,
},
},
});
if (!userSubscriptions || userSubscriptions.length === 0) {
//set user to not subscribed
await ctx.prisma.user.update({
where: {
id: ctx.session.user.id,
},
data: {
isSubscribed: false,
},
});
throw new TRPCError({ code: "UNAUTHORIZED" });
}
return next({
ctx: {
// infers the `session` as non-nullable
session: { ...ctx.session, user: ctx.session.user },
},
});
});
4 replies
TTCTheo's Typesafe Cult
Created by arete on 5/28/2023 in #questions
error when deploying at vercel
2 replies
TTCTheo's Typesafe Cult
Created by arete on 5/16/2023 in #questions
using Icon and getServerSideProps throws an error
is this a bug or an Error?
"use client"
import Layout from "@/components/dashboard/Layout";
import { PasienPlusPage } from "@/pages/_app";
import { getServerAuthSession } from "@/server/auth";
import { GetServerSidePropsContext } from "next";
import { ReactElement } from "react";
import { CameraIcon } from "lucide-react";


const accountsManagement: PasienPlusPage = () => {
return (
<>
<CameraIcon />
<h1>accountsManagement</h1>
</>
);
};

accountsManagement.getLayout = function getLayout(page: ReactElement) {
return <Layout>{page}</Layout>
}

accountsManagement.authRequired = true;
accountsManagement.isSubscriptionRequired = true;

export async function getServerSideProps(ctx: GetServerSidePropsContext) {
const session = await getServerAuthSession(ctx);

if (!session) {
return {
redirect: {
destination: "/auth/signin",
permanent: false,
},
};
}
// //if user is not admin redirect to dashboard
if (session?.user?.role === "user") {
return {
redirect: {
destination: "/dashboard/home",
permanent: false,
},
};
}


return {
props: { session },
};
}

export default accountsManagement;
"use client"
import Layout from "@/components/dashboard/Layout";
import { PasienPlusPage } from "@/pages/_app";
import { getServerAuthSession } from "@/server/auth";
import { GetServerSidePropsContext } from "next";
import { ReactElement } from "react";
import { CameraIcon } from "lucide-react";


const accountsManagement: PasienPlusPage = () => {
return (
<>
<CameraIcon />
<h1>accountsManagement</h1>
</>
);
};

accountsManagement.getLayout = function getLayout(page: ReactElement) {
return <Layout>{page}</Layout>
}

accountsManagement.authRequired = true;
accountsManagement.isSubscriptionRequired = true;

export async function getServerSideProps(ctx: GetServerSidePropsContext) {
const session = await getServerAuthSession(ctx);

if (!session) {
return {
redirect: {
destination: "/auth/signin",
permanent: false,
},
};
}
// //if user is not admin redirect to dashboard
if (session?.user?.role === "user") {
return {
redirect: {
destination: "/dashboard/home",
permanent: false,
},
};
}


return {
props: { session },
};
}

export default accountsManagement;
1 replies
TTCTheo's Typesafe Cult
Created by arete on 5/14/2023 in #questions
runtime error when using getServerSideProps
HI guys, i got this project where im gonna protect using getServerSideprops and next auth, so users cant access admin page, i made the function that can be called inside gssp.
1 replies
TTCTheo's Typesafe Cult
Created by arete on 5/13/2023 in #questions
Error when using getServerSideProps
5 replies
TTCTheo's Typesafe Cult
Created by arete on 5/12/2023 in #questions
is there a way to change/refresh token when data in db changes such as role?
Hi, I had a project using NextAuth as my provider and the JWT strategy. When I use the database strategy, whenever I change the user’s role, they are automatically redirected to their own page. However, when I use the JWT strategy, I have to log out and log in again to get the newest token. Is there any way I can change the behavior so the token automatically refreshes when I change the role?
6 replies
TTCTheo's Typesafe Cult
Created by arete on 4/17/2023 in #questions
Call retries were exceeded when generating static page using serversidehelpers
4 replies
TTCTheo's Typesafe Cult
Created by arete on 4/14/2023 in #questions
trpc routerOutputs
8 replies
TTCTheo's Typesafe Cult
Created by arete on 4/8/2023 in #questions
handle onError mutation
15 replies