Users and Profiles
Elements fully supports Users and Profiles that allow users of your application or game to store their profile data and access a network of applications from a single login profile.
Elements uses a one-to-many model for the User / Profile relationship. A Profile is linked directly to both one single Application and one single User.
As Elements is a multi-tenant system, there can be many Applications that allow for many Profiles per Application.
This structure gives you the flexibility to create a network of Applications under the same roof, with any User level information, such as Inventory, accessible in every Application should you so choose.
User Properties
A User has the following properties:
id
name
email
level
UNPRIVILEGED - An unprivileged/anonymous user.
USER - A basic user.
SUPERUSER - An administrator/super user, who can do all of the above as well as delete/create users.
active - Inactive Users will not appear in searches made by non-superuser level users.
FacebookId
AppleSignInId
Managing Users in the Console
Users are managed in the Users section of the admin console, which can be accessed from the upper nav bar or in the hamburger menu.
The "Add User" button will open the new user panel.
Users can be edited by tapping the "Edit" button next to that user, or can be deleted by tapping the "Delete" button. Use the search function to more easily find specific users.
Passwords can be set or changed using the admin console as well. In the database, they are salted and hashed and can't be manipulated directly.
JSON Structure of Users
Here is a sample of a user JSON entry from the database:
Profile Properties
A Profile has the following properties:
Id
User - The User that this Profile is linked to.
Application - The Application that this Profile is linked to.
ImageUrl - Any associated avatar image.
DisplayName - The name that should be displayed on the client side.
Metadata - Key/Value store that can be modified.
LastLogin - The time that the current session token was created (MS since epoch)
Once created, only the DisplayName and ImageUrl can be modified from the client side (via ProfilesApi). However, other properties, such as the Metadata, can be modified from the server side.
Profile Metadata
As mentioned in the previous section, the Profile metadata is a key/value store for just about anything that you'd want to be publicly facing (as Inventory is private) in a Profile. This is a great place for storing info that you might want different Profiles to know about each other. For example, say you have a game where someone can earn points to increase a numeric rank. In order to see that information, it needs to be stored in a publicly accessible place. Take this wireframe image for example:
All of the stats listed in this screen would be housed by the Profile metadata, so the JSON representation might look something like this:
Modifying Profile Metadata
In your Lua code, you can access the Profile DAO directly. For example:
You can then use this to update the Profile metadata via one of two methods:
Lua tables are automatically converted to the correct Java type.
To continue the example, take this sample endpoint code:
Managing Profiles Using the Console
Profile metadata is edited identically to how item metadata is edited. See Editing Item Metadata.
Profiles can be added, edited, or deleted from the admin console in the Profiles section, accessible from the top nav bar or the hamburger menu.
Since Profiles must be connected to a user, when making a new profile you can use the "Select User" button to find the user that will own this profile. If you are editing an existing profile, you can use the "Edit User" button to open the Edit User panel for that user. Existing profiles cannot be reassigned to another user.
When creating a new profile, you must also select an Application. A dropdown menu will open with the available applications. If editing an existing profile, the Application may not be changed.
JSON Structure of Profile
This is a sample profile represented in JSON:
Last updated