JMap.User.addInfo
Add a custom user info, stored in the redux store (JMap Core), and displayed in the user panel (JMap App).
The user info
JMap.User.changeFullName
For JMapCloud only.
Changes the user's full name.
The user's new full name.
JMap.User.changePassword
Change the user password on JMap server
The user new password
The user current password
JMap.User.getAllInfos
Returns all user informations. It is possible to add custom user information, available in the redux store and displayed in the user panel.
This function returns all custom informations.
JMap.User.getFullName
Returns user full name.
JMap.User.getMinimumPasswordLength
Returns the minumum password length defined in JMap Core
JMap.User.getOrganizationId
Returns the currently logged in user's organization, if the server is a JMap Cloud server, otherwise an empty orgnization object.
Organizations are only defined when connected to a JMap Cloud server instance.
JMap.User.getOrganizationId
Returns user's organization id.
If server is not a JMap Cloud server, or if the user in not logged in, will return an empty Id
Organizations are only defined when connected to a JMap Cloud server instance.
JMap.User.getPasswordPolicyCompliance
Returns an object describing the password compliance with the platform's password policy (JMap Server or JMap Cloud)
JMap.User.getPreference
Get a user preference value from user storage. The returned Promise resolves to the value, else null if no preference has been set. Rejects on error, or if name parameter is not string or empty string, or if no user is logged in
the name of the preference
a Promise that resolves with the value from the user storage (or null if the preference is not set).
JMap.User.getToken
If user is logged in, returns the current user session token.
Else returns "-1" if user has no active session.
JMap.User.getUsername
Returns the username (the one used to login).
JMap.User.hasPreference
Check for a user preference existence. The returned Promise resolves with true if a value has been set for the user preference, else false. Rejects on error, or if name parameter is not string or empty string, or if no user is logged in
the name of the preference
a Promise that resolves with true if a value has been set for the user preference, else false
JMap.User.isLoggedIn
Returns true if a user is logged in.
JMap.User.isPasswordCompliant
Returns true if the password complies with the platform's password policy (JMap Server or JMap Cloud), false otherwise.
JMap.User.isPseudoUser
Returns true if the currently logged in user is a JMap pseudo user (ex: system, anonymous, etc...).
JMap.User.isSystemUser
Returns true if the currently logged in user is a JMap system user (typically when NG is openned from JMap Admin).
JMap.User.login
The login function, returns a promise. Make a call to the server and if login is successful resolve the promise providing the user session data.
If an error occurs, 3 differents string message can be returned :
JMap.User.loginIntoOrganization
For JMapCloud only.
Sets and returns Session Data specific to a JMap Cloud organization. You need to be previously authenticated via the JMap.User.login method before calling this method. This method can also be used to switch between organizations while a user is already logged in.
JMap.User.loginWithIdentityProvider
Logs in the user using the specified Identity Provider. See JMap.Server.getAllIdentityProvidersById for info about Identity providers
JMap.User.logout
Logout function. Make a call to the server to invalidate the session id.
If an error occurs, 2 differents string message can be returned :
JMap.User.removeInfo
Remove a user info, from the redux store (JMap Core) and in the user panel (JMap App).
The user info id
JMap.User.removePreference
Remove a user preference from user storage. The returned Promise resolves with the value of the removed preference, or null if the preference does not exist.
Rejects on error, or if name parameter is not string or empty string, or if no user is logged in
the name of the preference
let prefName = "jmap-core-basemap"
JMap.User
.removePreference(prefName)
.then(removedPreferenceValue => {
if (removedPreferenceValue === null) {
console.log(Preference item "${prefName}" did not exist or was not removed
)
} else {
console.log(Preference item "${prefName}" has been removed. Value was: ${removedPreferenceValue}
)
}
})
a Promise that removes the user preference, and resolves with the value of the removed preference, or null if the preference does not exist
JMap.User.setPreference
Set a user preference in user storage. The returned Promise resolves without value on success. Rejects with a reason on error, or if name parameter is not string or empty string, or if no user is logged in If passed value is undefined, the preference is removed
the name of the preference
the value that will be associated to the name
a Promise that sets the user preference, and resolves with no value, or rejects with a reason
JMap.User.setToken
Sets the user session data. Useful if you want to make a call to our Rest API and set the session token by yourself.
This process is a bit different for JMap Server than for JMap CLoud.
For JMap Server, you need to fetch a session token from the REST API, and call JMap.User.setToken without spedifying the organization Id.
For JMap Cloud, you need to fetch a refresh token from the JMap Cloud Rest API, and pass this refresh token, along with the the optional organisation Id, to the JMap.User.setToken method. Beware that a refresh token can only be used once, it is invalidated afterward
Fetching data from a REST API can be done with the curl command-line tool (https://curl.haxx.se/docs/)
a JMap Server example:
# getting a session token from JMap Server
curl -X POST "https://my-jmap-server/services/rest/v2.0/session" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"username\": \"jdo@company.com\", \"password\": \"xxx\", \"type\": \"NG\"}"
will return something like:
{
"message": "The result is a NG session info",
"status": "OK",
"result": {
...
"sessionId": 23558109, // session id in the Rest API response is the session token.
...
}
}
a JMap Cloud example:
# getting a session token from JMap Cloud
curl --request POST \
--url https://api.jmapcloud.io/api/ss/rest/v1/authenticate \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"username": "jdo@company.com",
"password": "xxx"
}
'
will return something like:
{
"message": "The result is the access and refresh tokens",
"result": {
"accessToken": "eyJhbGciOiJ [.....] 6qwoKzNXMML4oGyNP6Vw_fCC58LCb7YQnY431BaTmxMNswr0HKMN0PQ",
"refreshToken": "v1.MRq [.....] Rehef72YWws",
"accessTokenExpireAt": "2022-12-24T17:31:33.429+00:00",
"accessTokenExpiration": 86400
}
}
JMap.User
From this section you can manage the user session.