Activity
Mon
Wed
Fri
Sun
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
What is this?
Less
More

Memberships

University of Code

5.3k members • Free

9 contributions to University of Code
Need help with React...
How do I pass the content of a useState variable from one jsx file to another jsx file?
2 likes • May '24
U can use useContext or pass that name to that jsx
2 likes • May '24
U can use custom useState
Firebase with next auth with credentials using roles
When I sign up with admin or user it is storing in firebase firestore that user is a admin or user but auth.ts in callbacks jwt with token i can't fetch that role can anyone help
1 like • May '24
Thank you brother ,"use server" import * as z from "zod" import { RegisterSchema } from "@/schemas"; import { db } from "@/firebase/clientApp"; import { addDoc, collection, query, where, doc, getDoc, getDocs } from 'firebase/firestore'; import bcrypt from "bcryptjs" import { getUserByEmail, getUserByName} from "@/data/user"; export const Adminsignupforms =async (values:z.infer<typeof RegisterSchema>)=>{ const validatedFields=RegisterSchema.safeParse(values); if(!validatedFields.success){ return {error:"Invalid fields!"}; } const {email,password,name,isActive,role}=validatedFields.data; const hashedPassword=await bcrypt.hash(password,10); const existingemail=await getUserByEmail(email); const existingname=await getUserByName(name); if (existingemail) { return { error: "Email is already in use!" }; } if(existingname){ return { error: "Username is already in use!" }; } await addDoc(collection(db, 'users'), { name, email, password: hashedPassword, role, isActive, }); return {success:"User created"} }, if i use custom claims it will be more complex? Or without using custom claims I need that role to in I can't use like that? import NextAuth from "next-auth" import authConfig from "./auth.config" import {getUserById, getUserByRole} from "@/data/user" import { adminDb } from "./firebase/admin" import { FirestoreAdapter } from "@auth/firebase-adapter" export const { handlers,auth,signIn,signOut } = NextAuth({ callbacks:{ async session({token,session}){ console.log({sessionToken:token}) if(token.sub && session.user){ session.user.id=token.sub; } if(token.role && session.user){ session.user.role=token.role } return session }, async jwt({token}){ if (!token.sub) return token; const existingUser = await getUserById(token.sub); if (existingUser) { token.role = existingUser.role; } return token } }, adapter:FirestoreAdapter(adminDb), session:{strategy:"jwt"}, ...authConfig, })
1 like • May '24
if (existingUser) { token.role = existingUser.role; } When I do this I am getting existingUser.role =role I did with console too it shows me undefined
Firebase database
I have a question. Do you need to pay for firebase to create a database? As I'm trying to connect my server to firebase and eventually retrieve images from there.
0 likes • May '24
If ur developing u can use firebase emulator they provider for testing mode u can check the docs
The LINKEDIN 2.0 Clone is ALMOST done!!!!
Im so close... this is a proper FULL STACK build - built an entire API backend with all types of different REST requests to add a little few extra gems in this next build!
The LINKEDIN 2.0 Clone is ALMOST done!!!!
3 likes • Apr '24
Awesome brother can't wait to see it #papafam🔥🔥
It’s 2:16am & here’s my honest thoughts.
I cannot describe how crazy this journey has been - from having a pure clear as day vision to stepping one step forward at a time. I understand the self doubt. I understand the imposter syndrome. I understand the pain of feeling like you are not smart enough for this field. But here’s the truth… you are WAY smarter than you realise - you have so much untapped potential and it’s only TRULY ever going to exist in the world if you start with a simple step - close your eyes & I want you to envision your dream life, that dream moment when you can truly say “holy shit we fu**ing did something special here”. This is manifestation, this is how you turn a vision into passion & how you excel far beyond the taught “10,000 hours to become an expert” mindset, we are never an expert - we remain open to new information, new ideas, new challenges & we embrace the fear and anxiety as this is quite honestly the BEST unlimited source of power you’ll forever have beside you. Motivation fades, the vision remains. We are great. We live without regrets. We are the #PAPAFAM
It’s 2:16am & here’s my honest thoughts.
3 likes • Apr '24
🔥🔥#papafam let's do it 🔥🔥
1-9 of 9
Saiguna Vanam
3
44points to level up
@saiguna-vanam-4396
I am a student learning to become full stack developer

Active 497d ago
Joined Apr 18, 2024
Powered by