Skip to content
Back

How to get account from user ID?

  • 0
  • Self Hosted
  • Accounts
  • General
  • Web
kathelia.dokgu
29 Jul, 2023, 20:56

I'm working on a scenario - a user registers and is sent a verification email. This user ignores the email for a while and then clicks on the link after it expires.

At this point I only have the userId, the secret, and the expire query params. I want to display to the user that the link has expired but then also allow them to send a new link by a click of a button or something. But sending another verification email requires that the user has an active session but at this point I no longer have the email and the password they used to register, I basically only have the userId.

I couldn't find anything on the docs - account.get() doesn't seem to accept any parameters. And I also couldn't find a function to call where I simply pass the userId and I'll get the account info.

What's the proper flow for expired verification emails?

TL;DR
User wants to find a way to get the account information of a user from their user ID. They want to use this information to create an email session and send a new verification email if the previous one expired. The proper flow for handling expired verification emails is not mentioned.
Matej
29 Jul, 2023, 21:00

It's server side

Matej
29 Jul, 2023, 21:00

But you can make a Appwrite Function that uses this and then execute it on the client side

kathelia.dokgu
29 Jul, 2023, 21:01

Thank you - I think I read somewhere that accounts aren't the same as users. If I use this and get the user from the userId, will I be able to create an email session for this user and then send another verification email?

Matej
29 Jul, 2023, 21:03

Yeah I don't see why not.

You get whole user object back in a payload https://appwrite.io/docs/models/user and you can use it for whatever.

You can do stuff with it on the client side, you can do stuff with it in the appwrite function, you can pass it to another appwrite function if needed

Matej
29 Jul, 2023, 21:04

Just note that function is server side, and read carefully what user object has. If there is some data that does not need to go back to the client, omit it

Matej
29 Jul, 2023, 21:05

Like password. If you don't need password, don't send it around

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more