iPheNoMeNaL-oG
iPheNoMeNaL-oG
Explore posts from servers
BABetter Auth
Created by Katsu on 2/28/2025 in #help
Calling signIn.social with extended field data.
Have you found a solution for this? I'm running into the same thing when I've added first/last name as additional fields.
5 replies
BABetter Auth
Created by iPheNoMeNaL-oG on 1/27/2025 in #help
Resend Verification Email
Still not triggering the resend email though
7 replies
BABetter Auth
Created by iPheNoMeNaL-oG on 1/27/2025 in #help
Resend Verification Email
oh wow I was running an outdate .env.local yikes
7 replies
BABetter Auth
Created by iPheNoMeNaL-oG on 1/27/2025 in #help
Resend Verification Email
hmmmm the verify is still originating from http://localhost:3000/api/auth/verify-email? ..
7 replies
BABetter Auth
Created by iPheNoMeNaL-oG on 1/27/2025 in #help
Resend Verification Email
oi my .env variable better auth url didnt match the client base url
7 replies
BABetter Auth
Created by iPheNoMeNaL-oG on 1/27/2025 in #help
Resend Verification Email
I can confirm sendVerificationEmail is being triggered
sendVerificaitonEmail being called {
id: 'UjmfxjTzc5ilfeheTQhfDQ0Ah6HlXgGb',
name: 'Yup',
emailVerified: false,
image: null,
createdAt: 2025-01-22T17:51:29.620Z,
updatedAt: 2025-01-22T17:51:29.620Z,
role: 'admin',
banned: null,
banReason: null,
banExpires: null
} http://localhost:3000/api/auth/verify-email?token=12345&callbackURL=/dashboard
POST /api/auth/sign-in/email?currentURL=http%3A%2F%2Flocalhost%3A3001%2Fsign-in 403 in 3960ms
sendVerificaitonEmail being called {
id: 'UjmfxjTzc5ilfeheTQhfDQ0Ah6HlXgGb',
name: 'Yup',
emailVerified: false,
image: null,
createdAt: 2025-01-22T17:51:29.620Z,
updatedAt: 2025-01-22T17:51:29.620Z,
role: 'admin',
banned: null,
banReason: null,
banExpires: null
} http://localhost:3000/api/auth/verify-email?token=12345&callbackURL=/dashboard
POST /api/auth/send-verification-email?currentURL=http%3A%2F%2Flocalhost%3A3001%2Fsign-in 200 in 239ms
sendVerificaitonEmail being called {
id: 'UjmfxjTzc5ilfeheTQhfDQ0Ah6HlXgGb',
name: 'Yup',
emailVerified: false,
image: null,
createdAt: 2025-01-22T17:51:29.620Z,
updatedAt: 2025-01-22T17:51:29.620Z,
role: 'admin',
banned: null,
banReason: null,
banExpires: null
} http://localhost:3000/api/auth/verify-email?token=12345&callbackURL=/dashboard
POST /api/auth/sign-in/email?currentURL=http%3A%2F%2Flocalhost%3A3001%2Fsign-in 403 in 3960ms
sendVerificaitonEmail being called {
id: 'UjmfxjTzc5ilfeheTQhfDQ0Ah6HlXgGb',
name: 'Yup',
emailVerified: false,
image: null,
createdAt: 2025-01-22T17:51:29.620Z,
updatedAt: 2025-01-22T17:51:29.620Z,
role: 'admin',
banned: null,
banReason: null,
banExpires: null
} http://localhost:3000/api/auth/verify-email?token=12345&callbackURL=/dashboard
POST /api/auth/send-verification-email?currentURL=http%3A%2F%2Flocalhost%3A3001%2Fsign-in 200 in 239ms
7 replies
BABetter Auth
Created by iPheNoMeNaL-oG on 1/27/2025 in #help
Resend Verification Email
emailVerification: {
sendOnSignUp: true,
autoSignInAfterVerification: true,
sendVerificationEmail: async ({ user, url }) => {
console.log("sendVerificaitonEmail being called", user, url);
try {
await resend.emails.send({
from: "ATS <[email protected]",
to: user.email,
subject: "Email Verification",
react: VerificationEmail({
name: user.name || "User",
verificationLink: url,
}),
});
} catch (error) {
console.error("Error sending verification email:", error);
throw error;
}
},
},
emailVerification: {
sendOnSignUp: true,
autoSignInAfterVerification: true,
sendVerificationEmail: async ({ user, url }) => {
console.log("sendVerificaitonEmail being called", user, url);
try {
await resend.emails.send({
from: "ATS <[email protected]",
to: user.email,
subject: "Email Verification",
react: VerificationEmail({
name: user.name || "User",
verificationLink: url,
}),
});
} catch (error) {
console.error("Error sending verification email:", error);
throw error;
}
},
},
7 replies
PPrisma
Created by iPheNoMeNaL-oG on 7/15/2024 in #help-and-questions
Using upsert when `Notifications` table doesn't exist yet for user
It seems this is the way to create if it doesn't exist yet
await prisma.notifications.upsert({
where: { id },
update: {
type,
communication,
marketing,
social,
security,
mobile,
},
create: {
id,
userId,
type,
communication,
marketing,
social,
security,
mobile,
},
});
await prisma.notifications.upsert({
where: { id },
update: {
type,
communication,
marketing,
social,
security,
mobile,
},
create: {
id,
userId,
type,
communication,
marketing,
social,
security,
mobile,
},
});
but userId is not defined in create
3 replies
PPrisma
Created by iPheNoMeNaL-oG on 6/13/2024 in #help-and-questions
Updating user info in db using forms
this work correctly for and username is updated in the db
10 replies
PPrisma
Created by iPheNoMeNaL-oG on 6/13/2024 in #help-and-questions
Updating user info in db using forms
const defaultValues: Partial<ProfileFormValues> = {
bio: "Full stack software engineer interested in web3.",
urls: [
{ value: "https://shadcn.com" },
{ value: "http://twitter.com/something" },
],
};

export function ProfileForm({ session, updateUser }) {
const [username, setUsername] = useState(session.user.username);

useEffect(() => {
console.log("current session data", session);
}, []);

const form = useForm<ProfileFormValues>({
resolver: zodResolver(profileSchema),
defaultValues: {
...defaultValues,
username: username,
},
mode: "onChange",
});

const { fields, append } = useFieldArray({
name: "urls",
control: form.control,
});

async function onSubmit(data: ProfileFormValues) {
console.log("making sure this is original username", username);
toast({
title: "You submitted the following values:",
description: (
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
<code className="text-white">{JSON.stringify(data, null, 2)}</code>
</pre>
),
});
updateUser(session.user.id, data.username);
}
const defaultValues: Partial<ProfileFormValues> = {
bio: "Full stack software engineer interested in web3.",
urls: [
{ value: "https://shadcn.com" },
{ value: "http://twitter.com/something" },
],
};

export function ProfileForm({ session, updateUser }) {
const [username, setUsername] = useState(session.user.username);

useEffect(() => {
console.log("current session data", session);
}, []);

const form = useForm<ProfileFormValues>({
resolver: zodResolver(profileSchema),
defaultValues: {
...defaultValues,
username: username,
},
mode: "onChange",
});

const { fields, append } = useFieldArray({
name: "urls",
control: form.control,
});

async function onSubmit(data: ProfileFormValues) {
console.log("making sure this is original username", username);
toast({
title: "You submitted the following values:",
description: (
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
<code className="text-white">{JSON.stringify(data, null, 2)}</code>
</pre>
),
});
updateUser(session.user.id, data.username);
}
server action
async function updateUser(id: string, username: string) {
"use server";
console.log("updating user", id, username);
await prisma.user.update({
where: {
id: id,
},
data: {
username: username,
},
});
}

export default async function Profile() {
const session = await auth();
return (
<div className="flex min-h-screen w-full flex-col">
<main className="flex min-h-[calc(100vh_-_theme(spacing.16))] flex-1 flex-col gap-4 bg-muted/40 p-4 md:gap-8 md:p-10">
<div className="mx-auto grid w-full max-w-6xl gap-2">
<h1 className="text-3xl font-semibold">Settings</h1>
</div>
{session && <ProfileForm session={session} updateUser={updateUser} />}
</main>
</div>
);
}
async function updateUser(id: string, username: string) {
"use server";
console.log("updating user", id, username);
await prisma.user.update({
where: {
id: id,
},
data: {
username: username,
},
});
}

export default async function Profile() {
const session = await auth();
return (
<div className="flex min-h-screen w-full flex-col">
<main className="flex min-h-[calc(100vh_-_theme(spacing.16))] flex-1 flex-col gap-4 bg-muted/40 p-4 md:gap-8 md:p-10">
<div className="mx-auto grid w-full max-w-6xl gap-2">
<h1 className="text-3xl font-semibold">Settings</h1>
</div>
{session && <ProfileForm session={session} updateUser={updateUser} />}
</main>
</div>
);
}
10 replies
PPrisma
Created by iPheNoMeNaL-oG on 6/13/2024 in #help-and-questions
Updating user info in db using forms
Then inside my <ProfileForm/> client component I have the submit function of the form as the following
async function onSubmit(data: ProfileFormValues) {
console.log("making sure this is original username", username);
toast({
title: "You submitted the following values:",
description: (
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
<code className="text-white">{JSON.stringify(data, null, 2)}</code>
</pre>
),
});
// update user using data from the form
}
async function onSubmit(data: ProfileFormValues) {
console.log("making sure this is original username", username);
toast({
title: "You submitted the following values:",
description: (
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
<code className="text-white">{JSON.stringify(data, null, 2)}</code>
</pre>
),
});
// update user using data from the form
}
10 replies
PPrisma
Created by iPheNoMeNaL-oG on 6/13/2024 in #help-and-questions
Updating user info in db using forms
@Nurul (Prisma) Here's what I have setup for using server actions. In page.tsx for profile
import { ProfileForm } from "@/components/forms/profile-form";
import { auth } from "@/auth";
import prisma from "@/lib/prisma";

async function updateUser(id: string, data) {
"use server";
await prisma.user.update({
where: {
id: id,
},
data: {
username: data.username,
},
});
}

export default async function Profile() {
const session = await auth();
return (
<div className="flex min-h-screen w-full flex-col">
<main className="flex min-h-[calc(100vh_-_theme(spacing.16))] flex-1 flex-col gap-4 bg-muted/40 p-4 md:gap-8 md:p-10">
<div className="mx-auto grid w-full max-w-6xl gap-2">
<h1 className="text-3xl font-semibold">Settings</h1>
</div>

<ProfileForm session={session} />
</main>
</div>
);
}
import { ProfileForm } from "@/components/forms/profile-form";
import { auth } from "@/auth";
import prisma from "@/lib/prisma";

async function updateUser(id: string, data) {
"use server";
await prisma.user.update({
where: {
id: id,
},
data: {
username: data.username,
},
});
}

export default async function Profile() {
const session = await auth();
return (
<div className="flex min-h-screen w-full flex-col">
<main className="flex min-h-[calc(100vh_-_theme(spacing.16))] flex-1 flex-col gap-4 bg-muted/40 p-4 md:gap-8 md:p-10">
<div className="mx-auto grid w-full max-w-6xl gap-2">
<h1 className="text-3xl font-semibold">Settings</h1>
</div>

<ProfileForm session={session} />
</main>
</div>
);
}
I need to pass updateUser as a prop to <ProfileForm updateUser={updateUser}/> right?
10 replies
PPrisma
Created by iPheNoMeNaL-oG on 6/13/2024 in #help-and-questions
Updating user info in db using forms
Also is best to update by id instead of username?
10 replies