Rank 1: Thread
How can i add labels to users in auth, using User ID?
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 2: Process
This didnt work either
Rank 2: Process
I have looked at https://appwrite.io/docs/products/auth/labels but cant solve it anyways
Rank 2: Process
Chrome
And that only happens to premium in lowercase?
Rank 2: Process
i have never got "premium" to be applied. And it never works if you change the label to something similar as you had before, example "Sub" to "Subscription"
Rank 2: Process
it only works then i change label to something totaly diffrent
Rank 2: Process
and in the server console it always says that it worked and the new label is applied, but in reality, its not always applied
Rank 2: Process
its so unpredictable and that is why i cant figure it out
Rank 2: Process
it is just like appwrite is glitching randomly
Please provide a step by step guide where you are certain that this always happens
In bulletpoints
Because what you described sounds really weird
Rank 2: Process
yeah i know
Rank 2: Process
this is my return/page.tsx either way.
import { stripe } from "../utils/stripe";
import { updateUserLabels } from "@/lib/updateUserLabels";
interface SearchParams {
session_id: string;
}
async function getSession(sessionId: string) {
const session = await stripe.checkout.sessions.retrieve(sessionId);
return session;
}
export default async function CheckoutReturn({ searchParams }: { searchParams: SearchParams }) {
const sessionId = searchParams.session_id;
const session = await getSession(sessionId);
const userId = session.client_reference_id;
console.log("Retrieved session:", session);
if (session?.payment_status === "paid" && userId) {
console.log("Payment is successful, updating user labels...");
await updateUserLabels(userId, 'premium');
} else {
console.log("Payment is not successful or user ID is missing.");
}
return (
{session?.payment_status === "unpaid" ? (
Payment Failed
Payment did not work. Please try again.
) : session?.payment_status === "paid" ? (
Thank You!
We appreciate your subscription!
Your Stripe customer ID is: {session.customer as string}
Your User ID is: {session.client_reference_id}
) : (
Processing Payment
Please wait while we process your payment.
)}
);
}
Rank 2: Process
and updateUserLabels.ts
Rank 2: Process
Can you show me how you have set up the structure? I give up on appwrite soon, the old database was so stright forward
Rank 2: Process
Really appreciate the effort and support anyways
In all honesty this is a really weird issue and I can't pinpoint where the issue is. Your code does not say say much nor does it look wrong on first glance. You have to provide as much information as possible in order to make debugging easier. I can't reproduce this on my end so you have to provide a step for step guide when this error happens.
What do you mean Appwrite don't update? So you:
- Went to the user in the Appwrite console
- Updated labels to be premium
- Clicked update
- Refreshed the page and...
Rank 2: Process
No i run the code to add label to the user i min auth. And after my server side console says that it worked, i go to appwrite and refresh the page, and sometimes there is no label added to the user/or the old label is still there.
Rank 2: Process
yeah i understand, sry that i cant provide more information
So to clarify. This only happens when you run "your" code?
The one you sent in the chat?
Rank 2: Process
Now i got something intressting, look