Used to search by user, create new users, get the current user, or requestpassword reset.
The method adds OAuth2 as an available authentication type for a user.
const user = await System.users.search().where(f => f.email. eq('mail@example.com')).first(); const oauth2Record: OAuth2Record = {externalId: 'someId', providerId: 'someId'}; await System.users. addOAuth2Data(user, oauth2Record);
The method is used to initialize a new user.
For new users, email is a mandatory parameter. When you enter the new user’s data, you need to save the user using the UserItem.save method.
email
const newUser = System.users.create(); newUser.data.email = 'mail@example.com'; await newUser.save()
The allows initializing a new user in the Active status with filled out OAuth2 parameters.
const oauth2Record: OAuth2Record = {externalId: 'someId', providerId: 'someId'}; const authData: AuthData = {oauth2: [oauth2Record]}; const newUser = System.users.createWithAuthData(authData); newUser.data.email = 'mail@example.com'; await newUser.save()
The method returns the current user.
const currentUser = await System.users.getCurrentUser();
The method deletes OAuth2 as an available authentication type for a user.
const user = await System.users.search().where(f => f.email. eq('mail@example.com')).first(); const oauth2Record: OAuth2Record = {externalId: 'someId', providerId: 'someId'}; await System.users. removeOAuth2Data(user, oauth2Record);
The method generates a new link to restore a user’s password.
and sends it to the email passed as the parameter.
The method is used to search for users.
To search for items in the collection, use the Search object:
const users = await System.users.search() .where(f => f. email.eq('email@example.com')) .all();
Example of searching by a user’s status:
const users = await System.users.search() .where(u => u.__status.eq(UserStatus.Blocked)) .all();
Read more about using search in the Manage apps article.
Make a system user a lite user.
Use example:
const user = await System.users.search().where( f => f.email.eq('mail@example.com')).first(); await System.users. setInternalUserAsLite(user);
Make a lite user a system user.
const user = await System.users.search().where( f => f.email.eq('mail@example.com')).first(); await System.users. setLiteUserAsInternal(user);
Your review is successfully sent!
Feedback sent successfully
User object
Used to search by user, create new users, get the current user, or request
password reset.
Hierarchy
Methods
addOAuth2Data
The method adds OAuth2 as an available authentication type for a user.
const user = await System.users.search().where(f => f.email. eq('mail@example.com')).first(); const oauth2Record: OAuth2Record = {externalId: 'someId', providerId: 'someId'}; await System.users. addOAuth2Data(user, oauth2Record);Parameters
user: UserItemRef
oauth2Data: TOAuth2
Returns Promise<void>
create
The method is used to initialize a new user.
For new users,
emailis a mandatory parameter. When you enter the new user’s data, you need to save the user using the UserItem.save method.const newUser = System.users.create(); newUser.data.email = 'mail@example.com'; await newUser.save()Returns UserItem
createWithAuthData
The allows initializing a new user in the Active status with filled out OAuth2 parameters.
For new users,
emailis a mandatory parameter. When you enter the new user’s data, you need to save the user using the UserItem.save method.const oauth2Record: OAuth2Record = {externalId: 'someId', providerId: 'someId'}; const authData: AuthData = {oauth2: [oauth2Record]}; const newUser = System.users.createWithAuthData(authData); newUser.data.email = 'mail@example.com'; await newUser.save()Parameters
authData: AuthData
Returns UserItem
getCurrentUser
The method returns the current user.
const currentUser = await System.users.getCurrentUser();Returns Promise<CurrentUserItem>
removeOAuth2Data
The method deletes OAuth2 as an available authentication type for a user.
const user = await System.users.search().where(f => f.email. eq('mail@example.com')).first(); const oauth2Record: OAuth2Record = {externalId: 'someId', providerId: 'someId'}; await System.users. removeOAuth2Data(user, oauth2Record);Parameters
user: UserItemRef
oauth2Data: TOAuth2
Returns Promise<void>
requestPasswordRecovery
The method generates a new link to restore a user’s password.
and sends it to the email passed as the parameter.
Parameters
email: string
Returns Promise<void>
search
The method is used to search for users.
To search for items in the collection, use the Search object:
const users = await System.users.search() .where(f => f. email.eq('email@example.com')) .all();Example of searching by a user’s status:
const users = await System.users.search() .where(u => u.__status.eq(UserStatus.Blocked)) .all();Read more about using search in the Manage apps article.
Returns UserSearch
setInternalUserAsLite
Make a system user a lite user.
Use example:
const user = await System.users.search().where( f => f.email.eq('mail@example.com')).first(); await System.users. setInternalUserAsLite(user);Parameters
user: UserItemRef
Returns Promise<void>
setLiteUserAsInternal
Make a lite user a system user.
Use example:
const user = await System.users.search().where( f => f.email.eq('mail@example.com')).first(); await System.users. setLiteUserAsInternal(user);Parameters
user: UserItemRef
Returns Promise<void>
Feedback sent successfully
Thank you for your input