Jump to top

User

interface

Represents a user's profile information in your Firebase project's user database. It also contains helper methods to change or retrieve profile information, as well as to manage that user's authentication state.

Example 1

Subscribing to the users authentication state.

firebase.auth().onAuthStateChanged((user) => {
  if (user) {
    console.log('User email: ', user.email);
  }
});
Example 2
const user = firebase.auth().currentUser;

if (user) {
 console.log('User email: ', user.email);
}

Properties

displayName

</>

The user's display name (if available).

displayName: string | null;

email

</>
  • The user's email address (if available).
email: string | null;

emailVerified

</>
  • True if the user's email address has been verified.
emailVerified: boolean;

isAnonymous

</>

Returns true if the user is anonymous; that is, the user account was created with auth#signInAnonymously and has not been linked to another account with auth#linkWithCredential.

isAnonymous: boolean;

metadata

</>

Returns the UserMetadata associated with this user.

metadata: UserMetadata;

phoneNumber

</>

Returns the phone number of the user, as stored in the Firebase project's user database, or null if none exists. This can be updated at any time by calling User#updatePhoneNumber.

phoneNumber: string | null;

photoURL

</>

The URL of the user's profile picture (if available).

photoURL: string | null;

providerData

</>

Additional provider-specific information about the user.

providerData: UserInfo[];

providerId

</>

The authentication provider ID for the current user. For example, 'facebook.com', or 'google.com'.

providerId: string;

uid

</>
  • The user's unique ID.
uid: string;

Methods

delete

</>

Delete the current user.

delete(): Promise<void>;

getIdToken

</>

Returns the users authentication token.

getIdToken(forceRefresh?: undefined | false | true): Promise<string>;

getIdTokenResult

</>

Returns a firebase.auth.IdTokenResult object which contains the ID token JWT string and other helper properties for getting different data associated with the token as well as all the decoded payload claims.

getIdTokenResult(forceRefresh?: undefined | false | true): Promise<IdTokenResult>;

linkWithCredential

</>

Link the user with a 3rd party credential provider.

linkWithCredential(credential: AuthCredential): Promise<UserCredential>;

reauthenticateWithCredential

</>

Re-authenticate a user with a third-party authentication provider.

reauthenticateWithCredential(credential: AuthCredential): Promise<UserCredential>;

reload

</>

Refreshes the current user.

reload(): Promise<void>;

sendEmailVerification

</>

Sends a verification email to a user.

sendEmailVerification(actionCodeSettings?: ActionCodeSettings): Promise<void>;

toJSON

</>

Returns a JSON-serializable representation of this object.

toJSON(): object;

unlink

</>

Unlinks a provider from a user account.

unlink(providerId: string): Promise<User>;

updateEmail

</>

Updates the user's email address.

updateEmail(email: string): Promise<void>;

updatePassword

</>

Updates the users password.

updatePassword(password: string): Promise<void>;

updatePhoneNumber

</>

Updates the user's phone number.

updatePhoneNumber(credential: AuthCredential): Promise<void>;

updateProfile

</>

Updates a user's profile data.

updateProfile(updates: UpdateProfile): Promise<void>;