I am trying to make a registration flow for the next.js using node-appwriter sdk as SSR. I am trying to add email verification but isn't working giving some errors:
TypeScript
(role: application) missing scope account
I have gave all the scope permissions in the API. Then too getting this error. Anyone know then it will be great full.
My current register user code looks like:
TypeScript
"use server";
import { createAdminClient } from "@/lib/appwrite";
import { RegisterFormData, registerSchema } from "@/schemas/register";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import { AppwriteException, ID } from "node-appwrite";
export async function registerUser(data: RegisterFormData) {
const validatedData = registerSchema.safeParse(data);
if (!validatedData.success) {
return {
success: false,
errors: validatedData.error.errors.map((error) => ({
field: error.path.join("."),
message: error.message,
})),
}
}
const { fullName, email, password } = validatedData.data;
const { account } = await createAdminClient();
try {
await account.create(ID.unique(), email, password, fullName);
const session = await account.createEmailPasswordSession(email, password);
const cookieStore = await cookies();
cookieStore.set("custom-auth-session", session.secret, {
path: "/",
httpOnly: true,
sameSite: "strict",
secure: true,
});
await account.createVerification("http://rnhyg-2409-40c1-3085-5d34-d518-3aa8-c6ca-460d.a.free.pinggy.link/auth/verify-email");
redirect("/verify-email");
} catch (error) {
if (error instanceof AppwriteException) {
const response = JSON.parse(error.response ?? '{}') ?? {};
return {
success: false,
errors: [{ field: "general", message: response.message }],
};
} else {
return {
success: false,
errors: [{ field: "general", message: "An unexpected error occurred" }],
};
}
}
}
TL;DR
Developers are facing an email verification error while implementing registration flow in Next.js using node-appwrite SDK. The specific error is "role: application missing scope account". This issue could be due to missing scope permissions in the API configuration. To resolve this error, double-check the scope permissions in the API configuration to ensure the required permissions are granted for the account.Recommended threads
- Issues with uAuth
Hey everyone, is anyone experiencing 500 errors for the oauth flow starting today? Im in the fra region. My oauth flow used to work fine until today, now im get...
- Provider error when creating a function ...
- Cloud function deployment failures
When I run appwrite push functions, select the function I want to deploy, confirm with a YES, is starts deploying but goes into error. I need to repeat the ste...