Skip to main content

User

Management of the users of the application and obtaining the data of the authenticated user.


all​


_user.all() : java.util.List<Values>​

Description​

Gets the list of data for all users.

How To Use​
// Returns all existing users.
_out.json(_user.all())
Return​

( java.util.List )

List of all data for all users.


allByCode​


_user.allByCode(code: string) : java.util.List<Values>​

Description​

Gets all users from the alternative code.

How To Use​
// Lists users who have the sample code in the log.
const users = _user.allByCode("sample")
for (const user of users) {
_log.info(`User ${user.getString("name")}`)
}
Attributes​
NAMETYPEDESCRIPTION
codestringAlternative code that users may have associated.
Return​

( java.util.List )

List of users found for the alternative code.


allProvidersData​


_user.allProvidersData() : Values​

Return​

( Values )


_user.allProvidersData(userId: int) : Values​

Attributes​
NAMETYPEDESCRIPTION
userIdint
Return​

( Values )


authHistoryForceUnlock​


_user.authHistoryForceUnlock() : void​

Return​

( void )


_user.authHistoryForceUnlock(userId: int) : void​

Attributes​
NAMETYPEDESCRIPTION
userIdint
Return​

( void )


authHistoryLatest​


_user.authHistoryLatest() : Values​

Return​

( Values )


_user.authHistoryLatest(userId: int) : Values​

Attributes​
NAMETYPEDESCRIPTION
userIdint
Return​

( Values )


authHistoryLatestIsLocked​


_user.authHistoryLatestIsLocked() : boolean​

Return​

( boolean )


_user.authHistoryLatestIsLocked(userId: int) : boolean​

Attributes​
NAMETYPEDESCRIPTION
userIdint
Return​

( boolean )


checkAuthHistoryConsecutiveFailure​


_user.checkAuthHistoryConsecutiveFailure(id: int) : boolean​

Attributes​
NAMETYPEDESCRIPTION
idint
Return​

( boolean )


code​


_user.code() : string​

Description​

Gets the alternative code of the user who is authenticated.

How To Use​
// Auxiliary code of the authenticated user.
_log.info(`User Code: ${_user.code()}`)
Return​

( string )

Auxiliary code of the logged user.


create​


_user.create(dataUser: Values) : int​

Description​

Creates the new user.

How To Use​
// Create a new user:
const group = _group.firstByCode("samle")_user.create(
_val.map()
.set("name", "Full Name")
.set("mail", "user@sample.com")
.set("user", "username")
.set("pass", "SecretPassword123")
.set("group_id", group.getInt("id"))
// It is optional to define an auxiliary alternative code:
.set("code", "example-alternative-identification")
)
Attributes​
NAMETYPEDESCRIPTION
dataUserValuesData of the user to be created.
Return​

( int )

User ID that was created.


createIfNotExists​


_user.createIfNotExists(userData: Values) : boolean​

Description​

Creates the user if it does not exist yet.

How To Use​
// Create a new user if it doesn't exist yet:
const group = _group.firstByCode("generic")
_user.createIfNotExists(
_val.map()
.set("name", "Full Name")
.set("mail", "user@sample.com")
.set("user", "username")
.set("pass", "SecretPassword123")
.set("group_id", group.getInt("id"))
// It is optional to define an auxiliary alternative code:
.set("code", "example-alternative-identification")
)
Attributes​
NAMETYPEDESCRIPTION
userDataValuesData of the user to be created if it does not exist yet.
Return​

( boolean )

It was successfully created.


data​


_user.data() : Values​

Description​

It obtains all the data information of the user who is authenticated.

How To Use​
// All information of the authenticated user.
_out.json(_user.data())
Return​

( Values )

All data of the logged user.


firstByCode​


_user.firstByCode(code: string) : Values​

Description​

Gets a user's data from the alternate code.

How To Use​
// User who has the sample code.
const user = _user.firstByCode("sample")
_out.json(user)
Attributes​
NAMETYPEDESCRIPTION
codestringAlternative code that the user may have associated.
Return​

( Values )

User data found with the alternative code.


firstByMail​


_user.firstByMail(mail: string) : Values​

Description​

Retrieves a user's data from email.

How To Use​
// User obtained from email.
const user = _user.firstByMail("user@example.com")
_out.json(user)
Attributes​
NAMETYPEDESCRIPTION
mailstringUser e-mail.
Return​

( Values )

User data found with the email.


firstByName​


_user.firstByName(name: string) : Values​

Description​

Gets a user's data from the full name.

How To Use​
// User who has the full name.
const user = _user.firstByName("Full Name")
_out.json(user)
Attributes​
NAMETYPEDESCRIPTION
namestringFull name of the user.
Return​

( Values )

User data found with full name.


firstByUser​


_user.firstByUser(user: string) : Values​

Description​

It obtains a user's data from the user name, the same name used in the login.

How To Use​
// User from username.
const user = _user.firstByMail("user@example.com")
_out.json(user)
Attributes​
NAMETYPEDESCRIPTION
userstringUsername of the user.
Return​

( Values )

User data found with username.


get​


_user.get(id: int) : Values​

Description​

Gets a user's data from the ID (numeric identifier).

How To Use​
// User obtained from the ID.
const user = _user.get(1)
_out.json(user)
Attributes​
NAMETYPEDESCRIPTION
idintNumeric identifier of the user.
Return​

( Values )

User data found.


_user.get(idOrUidOrUsername: string) : Values​

Description​

It obtains a user's data from the ID (numeric identifier), the UUID (universal unique identifier) or the user name.

How To Use​
// User obtained from the UUID.
const user = _user.get("7901e01c-c53e-42c2-980d-9f928090422f")
_out.json(user)
Attributes​
NAMETYPEDESCRIPTION
idOrUidOrUsernamestringIt can be either an ID, or a UUID, or the username.
Return​

( Values )

User data found.


hasProvider​


_user.hasProvider(userId: int, providerCode: string) : boolean​

Attributes​
NAMETYPEDESCRIPTION
userIdint
providerCodestring
Return​

( boolean )


_user.hasProvider(providerCode: string) : boolean​

Attributes​
NAMETYPEDESCRIPTION
providerCodestring
Return​

( boolean )


id​


_user.id() : int​

Description​

Gets the numeric identifier of who is authenticated.

How To Use​
// Authenticated user ID.
_log.info(`User ID: ${_user.id()}`)
Return​

( int )

ID (numeric identifier) of the logged in user.


load​


_user.load() : User​

Return​

( User )


name​


_user.name() : string​

Description​

Gets the full name of the user who is authenticated.

How To Use​
// Authenticated user name.
_log.info(`Full name of the User: ${_user.name()}`)
Return​

( string )

Full name of the logged in user.


noPassword​


_user.noPassword(active: boolean) : boolean​

Attributes​
NAMETYPEDESCRIPTION
activeboolean
Return​

( boolean )


_user.noPassword(id: int, active: boolean) : boolean​

Attributes​
NAMETYPEDESCRIPTION
idint
activeboolean
Return​

( boolean )


password​


_user.password(id: int, password: string) : boolean​

Attributes​
NAMETYPEDESCRIPTION
idint
passwordstring
Return​

( boolean )


_user.password(password: string) : boolean​

Attributes​
NAMETYPEDESCRIPTION
passwordstring
Return​

( boolean )


providerData​


_user.providerData(userId: int, providerCode: string) : Values​

Attributes​
NAMETYPEDESCRIPTION
userIdint
providerCodestring
Return​

( Values )


_user.providerData(providerCode: string) : Values​

Attributes​
NAMETYPEDESCRIPTION
providerCodestring
Return​

( Values )


providerDataByUid​


_user.providerDataByUid(uid: string) : Values​

Attributes​
NAMETYPEDESCRIPTION
uidstring
Return​

( Values )


providerLDAP​


_user.providerLDAP(active: boolean) : boolean​

Attributes​
NAMETYPEDESCRIPTION
activeboolean
Return​

( boolean )


_user.providerLDAP(id: int, active: boolean) : boolean​

Attributes​
NAMETYPEDESCRIPTION
idint
activeboolean
Return​

( boolean )


remove​


_user.remove(id: int) : boolean​

Description​

Removes the user referring to the passed ID.

How To Use​
// Removes the user:
const user = _user.firstByCode("sample")
_user.remove(
user.getInt("id")
)
Attributes​
NAMETYPEDESCRIPTION
idintThe user's ID (numeric identifier).
Return​

( boolean )

It was successfully deleted.



_user.search(term: string) : java.util.List<Values>​

Description​

Searches for users who have an occurrence in the data with the past search text.

How To Use​
// Searches for users with the surname "Last Name".
const users = _user.search("Last Name")
for (const user of users) {
_log.info(`User found ${user.getString("name")}`)
}
Attributes​
NAMETYPEDESCRIPTION
termstringSearch key.
Return​

( java.util.List )

List of user data found.


searchFirst​


_user.searchFirst(term: string) : Values​

Description​

The first result of the user search that has any occurrence in the past term data.

How To Use​
// The first user to have an e-mail with @example.com.
const user = _user.search("@example.com")
_out.json(user)
Attributes​
NAMETYPEDESCRIPTION
termstringSearch key.
Return​

( Values )

User data found.


setNoPassword​


_user.setNoPassword(active: boolean) : boolean​

Attributes​
NAMETYPEDESCRIPTION
activeboolean
Return​

( boolean )


_user.setNoPassword(id: int, active: boolean) : boolean​

Attributes​
NAMETYPEDESCRIPTION
idint
activeboolean
Return​

( boolean )


setPassword​


_user.setPassword(id: int, password: string) : boolean​

Attributes​
NAMETYPEDESCRIPTION
idint
passwordstring
Return​

( boolean )


_user.setPassword(password: string) : boolean​

Attributes​
NAMETYPEDESCRIPTION
passwordstring
Return​

( boolean )


setProviderLDAP​


_user.setProviderLDAP(active: boolean) : boolean​

Attributes​
NAMETYPEDESCRIPTION
activeboolean
Return​

( boolean )


_user.setProviderLDAP(id: int, active: boolean) : boolean​

Attributes​
NAMETYPEDESCRIPTION
idint
activeboolean
Return​

( boolean )


uid​


_user.uid() : string​

Description​

Gets the universal unique identifier of who is authenticated.

How To Use​
// UUID of the authenticated user.
_log.info(`User UID: ${_user.uid()}`)
Return​

( string )

UUID (universal unique identifier) of the logged in user.


update​


_user.update(id: int, userData: Values) : boolean​

Description​

Updates user data for the past ID.

How To Use​
// Updates the user:
const userData = _user.firstByMail("user.mail@example.com")
userData.set("pass", "NewSecretPassword123")
_user.update(
userData.getInt("id"),
userData,
true
)
Attributes​
NAMETYPEDESCRIPTION
idintThe user's ID (numeric identifier).
userDataValuesUser data to update the information stored in the database.
Return​

( boolean )

It was successfully updated.


_user.update(id: int, userData: Values, changePassword: boolean) : boolean​

Description​

Updates user data for the past ID.

How To Use​
// Updates the user:
const userData = _user.firstByMail("user.mail@example.com")
userData.set("pass", "NewSecretPassword123")
_user.update(
userData.getInt("id"),
userData,
true
)
Attributes​
NAMETYPEDESCRIPTION
idintThe user's ID (numeric identifier).
userDataValuesUser data to update the information stored in the database.
changePasswordbooleanWhether to change the password or password.
Return​

( boolean )

It was successfully updated.


_user.update(userData: Values) : boolean​

Description​

Updates user data for the ID defined in the passed data structure.

How To Use​
// Updates the user:
const userData = _user.firstByMail("user.mail@example.com")
userData.set("pass", "NewSecretPassword123")
_user.update(
userData,
true
)
Attributes​
NAMETYPEDESCRIPTION
userDataValuesUser data to update the information stored in the database.
Return​

( boolean )

It was successfully updated.


_user.update(userData: Values, changePassword: boolean) : boolean​

Description​

Updates user data for the ID defined in the passed data structure.

How To Use​
// Updates the user:
const userData = _user.firstByMail("user.mail@example.com")
userData.set("pass", "NewSecretPassword123")
_user.update(
userData,
true
)
Attributes​
NAMETYPEDESCRIPTION
userDataValuesUser data to update the information stored in the database.
changePasswordbooleanWhether to change the password or password.
Return​

( boolean )

It was successfully updated.


user​


_user.user() : string​

Description​

Gets the full username of who is authenticated.

How To Use​
// Authenticated username.
_log.info(`Full name of the User: ${_user.user()}`)
Return​

( string )

Username of the logged in user.