Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs Menu
Docs Home
/ /
Administrar usuarios

Metadatos de usuario - SDK de Node.js

Puedes leer el metadatos de usuario de un usuario actualmente conectado a través de ese usuario User objeto. No se pueden editar los metadatos del usuario a través de un objeto User.

To read the data, access the profile property on the User object of a logged-in user:

try {
await app.logIn(
Realm.Credentials.emailPassword("someone@example.com", "Pa55w0rd!")
);
} catch (error) {
await app.emailPasswordAuth.registerUser({ "someone@example.com", "Pa55w0rd!" });
await app.logIn(
Realm.Credentials.emailPassword("someone@example.com", "Pa55w0rd!")
);
}
const userEmail = app.currentUser.profile.email;

User metadata options vary depending on which provider you're using and which metadata fields you enable.

Advertencia

User Metadata May Be Stale

Atlas App Services fetches the most recent version of user metadata when a user logs in. If the user changes their email address or profile photo with a login provider, for example, those changes do not update in user metadata until the user logs in again. Because we cache credentials and enable you to bypass the login flow, user metadata may become stale unless you force the user to log in again.

You can only read user metadata from the client app that you have configured on the App Services application.

Puede configurar los metadatos de usuario que solicita a un proveedor de autenticación. Esto se hace directamente en la configuración del proveedor. Para obtener más información sobre los campos de metadatos que puede usar, consulte los detalles del proveedor:

Puede cambiar qué campos de metadatos ha configurado editando la configuración del proveedor.

User metadata that you access through the authentication provider is read-only data. You cannot update or edit user metadata that comes from this source.

If you would like to give a user the option the update their metadata from within your client app, use custom user data, instead.

Volver

Custom User Data

En esta página