Skip to content

Latest commit

 

History

History
147 lines (131 loc) · 6.61 KB

File metadata and controls

147 lines (131 loc) · 6.61 KB

User

The IUser interface represents the User object defining the properties and their types that can be associated with a user. User information is stored in the users collection on MongoDB.

Main Interface

The main interface of a User object.

interface IUser {
	_id: string;
	createdAt: Date;
	roles: IRole['_id'][];
	type: string;
	active: boolean;
	username?: string;
	nickname?: string;
	name?: string;
	services?: IUserServices;
	emails?: IUserEmail[];
	status?: UserStatus;
	statusConnection?: string;
	lastLogin?: Date;
	bio?: string;
	avatarOrigin?: string;
	avatarETag?: string;
	avatarUrl?: string;
	utcOffset?: number;
	language?: string;
	statusDefault?: UserStatus;
	statusText?: string;
	oauth?: {
		authorizedClients: string[];
	};
	_updatedAt: Date;
	e2e?: {
		private_key: string;
		public_key: string;
	};
	requirePasswordChange?: boolean;
	customFields?: {
		[key: string]: any;
	};
	settings?: IUserSettings;
	defaultRoom?: string;
	ldap?: boolean;
	extension?: string;
	inviteToken?: string;
	canViewAllInfo?: boolean;
	phone?: string;
	reason?: string;
	federated?: boolean;
	federation?: {
		avatarUrl?: string;
		searchedServerNames?: string[];
	};
	banners?: {
		[key: string]: {
			id: string;
			priority: number;
			title: string;
			text: string;
			textArguments?: string[];
			modifiers: ('large' | 'danger')[];
			link: string;
			read?: boolean;
		};
	};
	importIds?: string[];
}

For more information and details on the Interface and sub-Interfaces, see the code here

{% embed url="https://github.com/RocketChat/Rocket.Chat/blob/develop/packages/core-typings/src/IUser.ts" %}

User Object

Example Object
{
    "_id": "gzvcvpov9G4TxbGFS",
    "createdAt": {
        "$date": "2023-03-02T17:59:43.415Z"
    },
    "services": {
        "password": {
            "bcrypt": "$2b$10$u..."
        },
        "email2fa": {
            "enabled": true,
            "changedAt": {
                "$date": "2023-03-02T17:59:43.415Z"
            }
        },
        "resume": {
            "loginTokens": []
        }
    },
    "username": "demouser",
    "emails": [
        {
            "address": "demo@email.com",
            "verified": true
        }
    ],
    "type": "user",
    "status": "offline",
    "active": true,
    "_updatedAt": {
        "$date": "2023-03-02T18:47:15.205Z"
    },
    "__rooms": [
        "GENERAL"
    ],
    "roles": [
        "user"
    ],
    "name": "demouser",
    "requirePasswordChange": false,
    "settings": {},
    "lastLogin": {
        "$date": "2023-03-02T18:14:28.122Z"
    },
    "statusConnection": "offline",
    "e2e": {
        "private_key": "{\"$binary\":\"m4E7yE/...==\"}",
        "public_key": "{\"alg\":\"RSA-OAEP-256\",\"e\":\"AQAB\",\"ext\":true,\"key_ops\":[\"encrypt\"],\"kty\":\"RSA\",\"n\":\"0pbPAF67...w\"}"
    },
    "utcOffset": 1
}

Fields

The User object has these fields with the following data types.

FieldData TypeDescription
_idstringThe unique identifier for the user.
createdAtDateThe date and time when the user was created.
rolesArray of stringsAn array of role IDs associated with the user. Eg "user", "admin", “livechat-agent”
typestringThe type of user. E.g. “user”, “app” or “bot”
activebooleanIndicates whether the user is active or not.
usernamestring The username of the user.
nicknamestring The nickname of the user.
namestring The name of the user.
servicesobject Additional services associated with the user.
emailsArray of objects An array of email objects associated with the user.
statusstring The status of the user.
statusConnectionstring The status connection of the user.
lastLoginDate The date and time of the user's last login.
biostring The biography or description of the user.
avatarOriginstring The origin of the user's avatar.
avatarETagstring The ETag of the user's avatar.
avatarUrlstring The URL of the user's avatar.
utcOffsetnumber The UTC offset of the user's timezone.
languagestring The language preference of the user.
statusDefaultstring The default status of the user.
statusTextstring The custom status text of the user.
oauthobject OAuth information associated with the user.
_updatedAtDateThe date and time when the user object was last updated.
e2eobject End-to-end encryption information associated with the user.
requirePasswordChangeboolean Indicates whether the user needs to change their password.
customFieldsobject Additional custom fields associated with the user.
settingsobject User-specific settings.
defaultRoomstring The ID of the user's default room.
ldapboolean Indicates whether the user is an LDAP user.
extensionstring The extension associated with the user.
inviteTokenstring The token for inviting the user.
canViewAllInfoboolean Indicates whether the user can view all information.
phonestring The phone number associated with the user.
reasonstring The reason associated with the user.
federatedboolean Indicates whether the user is a federated user.
federationobject Federation information associated with the user.
bannersobject Banner information associated with the user.
importIdsArray of strings An array of import IDs associated with the user.