cupofcrypto
cupofcrypto
TTCTheo's Typesafe Cult
Created by cupofcrypto on 6/20/2024 in #questions
How to build Drizzle explicit types
Thanks for your help, on mobile now so just wanted to thank you as soon as I saw this. I'll get back to you once I'll be working with a keyboard 😅
4 replies
TTCTheo's Typesafe Cult
Created by cupofcrypto on 2/16/2024 in #questions
Build a component library for Next.js w/ shadcn/ui
Is this question too silly or no-one had this need yet?
3 replies
TTCTheo's Typesafe Cult
Created by ideceddy on 2/23/2024 in #questions
Sharing data across client & server components?
I faced a similar issue recently implementing auth with a custom BE. In the end I solved leveraging httpOnly cookies... On the client, with Redux, I let the user login into the app. Once that's done, I use the cookie for the following REST calls and I pass the data down to the client when needed.
Currently I am thinking of a refactor to test few ideas, but I also have to ship new features so we will see 😅
4 replies
TTCTheo's Typesafe Cult
Created by cupofcrypto on 2/1/2024 in #questions
Auth.js v5 issue with UntrustedHost
still have to implement it tbh, this GH issue has good info about that and also Auth.js has docs about that my main issue is with UntrustedDomain
11 replies
TTCTheo's Typesafe Cult
Created by cupofcrypto on 2/1/2024 in #questions
Auth.js v5 issue with UntrustedHost
I am not using T3 for this project, as I wrote at the beginning I have an external server and I login via REST API
11 replies
TTCTheo's Typesafe Cult
Created by cupofcrypto on 2/1/2024 in #questions
Auth.js v5 issue with UntrustedHost
no issue at all but I believe that my code needs a lot of improvements 😅 If you login with a REST API does not matter which language has been chosen by the server. In my case I have an BE/auth/signin endpoint that accepts email:password and responds just with the access_token and the refresh_token With v4 I saw that bot get injected in the session, but in v5 it didn't happen. I had not time to investigate because right now I am under pressure to respect the sprint, i've allocated time to refactor/investigation for next one. Anyway, in order to populate the session I had to use the jwt and session callbacks like this:
// Part of auth.ts
callbacks: {
async jwt({ token, user }) {
// I have to call `/users/me` to get the user data
if (token.access_token) {
const res = await fetch(`${process.env.BACKEND_URL}/users/me`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token.access_token}`,
},
});

const {
person: { dossiers, ...person },
...rest
} = await res.json();

const res_user = { ...rest, person }
;
return { ...token, user: res_user };
}

return { ...token, ...user };
},
async session({ session, token }) {
session.user = token.user;
session.access_token = token.access_token;
session.refresh_token = token.refresh_token;
session.exp = token.exp;

return session;
},
},
session: {
strategy: "jwt",
},
// Part of auth.ts
callbacks: {
async jwt({ token, user }) {
// I have to call `/users/me` to get the user data
if (token.access_token) {
const res = await fetch(`${process.env.BACKEND_URL}/users/me`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token.access_token}`,
},
});

const {
person: { dossiers, ...person },
...rest
} = await res.json();

const res_user = { ...rest, person }
;
return { ...token, user: res_user };
}

return { ...token, ...user };
},
async session({ session, token }) {
session.user = token.user;
session.access_token = token.access_token;
session.refresh_token = token.refresh_token;
session.exp = token.exp;

return session;
},
},
session: {
strategy: "jwt",
},
11 replies
TTCTheo's Typesafe Cult
Created by Deras on 9/26/2023 in #questions
Looking for 1-3 hour long Next tutorial, app router, server comp., server actions, local db, auth.js
this is really good material, I still facing few issues with Auth.js but this is another topic 😅
16 replies
TTCTheo's Typesafe Cult
Created by Deras on 9/26/2023 in #questions
Looking for 1-3 hour long Next tutorial, app router, server comp., server actions, local db, auth.js
this is a great channel as well, rich of up to date tutorials and on his website you can unlock content that goes even further https://www.youtube.com/@codewithantonio
16 replies
TTCTheo's Typesafe Cult
Created by cupofcrypto on 9/20/2023 in #questions
Not sure how to move forward with NextAuth and Web3
once I have their wallet on DB, I can check NFT presence even if they are not web3 authenticated
11 replies
TTCTheo's Typesafe Cult
Created by cupofcrypto on 9/20/2023 in #questions
Not sure how to move forward with NextAuth and Web3
at the end of the day, I will not use the web3 auth to allow/disallow access to the platform. I want them able to sign with a wallet because: - they need to proof that their are the owners of the wallet - I would like them to mint an NFT via the Unlock Protocol
11 replies
TTCTheo's Typesafe Cult
Created by cupofcrypto on 9/20/2023 in #questions
Not sure how to move forward with NextAuth and Web3
that's my idea tbh. handle the standard login with NextAuth and allow user to authenticate later in their "profile page" with the wallet. as soon as I have the wallet address I'll store it in their profile table
11 replies
TTCTheo's Typesafe Cult
Created by cupofcrypto on 9/20/2023 in #questions
Not sure how to move forward with NextAuth and Web3
yup and with that one I am aligned on moving on the third option because otherwise we do not have a way to store user informations in the database. On top of that, I do have few beta users that are using the platform and I have no clue on how to merge the information on their session with the web3 auth
11 replies
TTCTheo's Typesafe Cult
Created by gave_one on 8/5/2023 in #questions
API handler should not return a value, received object.
do you mind explain how? I am facing this issue right now and looks to me that I haven't changed anything related to Auth 🤔
5 replies
TTCTheo's Typesafe Cult
Created by cupofcrypto on 8/22/2023 in #questions
Best approach to limit free users
ehehehehehe you're totally right and thanks for the support, I'll reach out later in case I face some issues or want to say "mission accomplished" 😅
12 replies
TTCTheo's Typesafe Cult
Created by cupofcrypto on 8/22/2023 in #questions
Best approach to limit free users
my last point was that I am not a master in request processing and I was wondering how to leverage the error I'll receive from my API when user will click the "Create new task" button and already has 5 items. But probably this is more because I haven't wrote a single line of code yet. If you have any article/tutorial/codebase that you can share with me I'll be incredibly grateful
12 replies
TTCTheo's Typesafe Cult
Created by cupofcrypto on 8/22/2023 in #questions
Best approach to limit free users
mmm tbh while the user visit the platform I don't have needs to "lock" anything he sees, because at the end these are "his stuff". but is upon a specific action that I want to limit his power. If we take a ToDo List app as an example, I want that free users only have 5 items and they cannot create a new item if they already have 5 in their list. They'll need to complete/delete one or pay the subscription.
12 replies
TTCTheo's Typesafe Cult
Created by cupofcrypto on 8/22/2023 in #questions
Best approach to limit free users
Yup, I am definitely mixing those two 😂
12 replies
TTCTheo's Typesafe Cult
Created by cupofcrypto on 8/22/2023 in #questions
Best approach to limit free users
checking it closely, the demo app of shadcn does not uses tRPC and instead leverages the RSC (as supposed by the scope of the app 😊) making db queries right in the page. The thing is that he handles the response right in the handler funcition with the fetch request. https://github.com/shadcn-ui/taxonomy/blob/main/components/post-create-button.tsx#L36-L50 How could I build the same logic with React Query? I'll have the error variable returned right?
12 replies
TTCTheo's Typesafe Cult
Created by cupofcrypto on 8/19/2023 in #questions
Typescript errors with `cloneElement`
To whom would be interested in the future this is how I solved the errors. Not proud because I am not sure it is the best code, but at least it gets the job done.
// Made in order to solve some issues with `cloneElement`
type ChildrenProps = {
className?: string;
};

children.map((child: ReactElement<ChildrenProps>) => {
if (!isValidElement(child)) return child;

return cloneElement(child as ReactElement, {
className: cn(child.props.className as ClassValue, {
block: isOverflowing,
}),
});
});
// Made in order to solve some issues with `cloneElement`
type ChildrenProps = {
className?: string;
};

children.map((child: ReactElement<ChildrenProps>) => {
if (!isValidElement(child)) return child;

return cloneElement(child as ReactElement, {
className: cn(child.props.className as ClassValue, {
block: isOverflowing,
}),
});
});
4 replies
TTCTheo's Typesafe Cult
Created by zyrixqe on 7/22/2023 in #questions
How can I use login with username and password using NextAuth from T3-App?
You let me discover that Auth.js let user login also with Went wallets 🎉 Thanks, didn't know it was possible 😅
8 replies