Skip to content

FB4D Reference IFirebaseUser

Christoph Schneider edited this page Jun 21, 2023 · 3 revisions

Interface IFirebaseUser

This interface provides only getter functions that are used to retrieve details of the user profile and the access token.

Get User Identification UID

To identify a user, Firebase defines the UID as a random string of 28 characters of the following alphabet:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 

Get EMail Address

Check if an email address exists:

function IsEMailAvailable: boolean;

Check whether the email is for an existing account:

function IsEMailRegistered: TThreeStateBoolean;

Returns true if the user's email is verified:

function IsEMailVerified: TThreeStateBoolean;

Retrieve the email address of the user:

function EMail: string;

Get User Display Name

Normally, the user's display name allows the user to choose freely and is used for display within an application (for example, a chat). Note that Firebase does not ensure that there is only one user with the same name for this field.

function IsDisplayNameAvailable: boolean;
function DisplayName: string;

Get Photo URL for User Avatar or Photo

To identify the user via a photo or avatar the PhotoURL can be used:

function IsPhotoURLAvailable: boolean;
function PhotoURL: string;

Get User Account State and Timestamps

Returns true if the user account was disabled:

function IsDisabled: TThreeStateBoolean;

Returns true if the user new created:

function IsNew#User: boolean;

Is the timestamp of the last login available?

function IsLastLoginAtAvailable: boolean;

Timestamp of the last login:

function LastLoginAt(TimeZone: TTimeZone = tzLocalTime): TDateTime;

When was the user registered in Firebase?

function IsCreatedAtAvailable: boolean;
function CreatedAt(TimeZone: TTimeZone = tzLocalTime): TDateTime;

Get Token Details and Claim Fields

Return the access token as a string:

function Token: string;

When will the access token be expired:

function ExpiresAt: TDateTime;

In order to refresh the access token without to re-sign-in the refresh-token needs to be sent to the Firebase Authentication Service. This will be done usually automatically within the FB4D. Use the following function to retrieve the update token:

function RefreshToken: string;

The following 3 functions are available only when the conditional compiling switch TOKENJWT is defined. For more details see the next chapter ITokenJWT

function TokenJWT: ITokenJWT;

This function returns a list with all claim field names in the JWTToken. In addition to the standard fields of the Firebase Authorization Service, it is possible to add also project-specific fields on server side by writing a Firebase Function that extends the JWTToken. This can be used for example to integrate an own access level into the token.

function ClaimFieldNames: TStrings;

This function returns the content of a claim-field as a JSON value.

function ClaimField(const FieldName: string): TJSONValue;
Clone this wiki locally