CurrentUser
The CurrentUser
class extends the SessionSingleton
class from Aura
(see Auth Core docs for more information) is used throughout Group Control, but is available to you to use in every Controller, as was suggested above. Thus this is the session for the currently logged in user, and has information from their Group Control user model, which can be helpful to know, as well as Session related information.
Properties Available in Current User
There are many properties that are accessible about the CurrentUser, through this user option. These are only accessible through the functions, which will be described in a second (such as get
), but all of the information saved to the user is the following:
id
: The Group Control userID of the User model (especially helpful for saving data to the current user in various tables to the database).nameFirst
,nameLast
, andnamePref
: The information of the user's name in Group Control.email
: The email for the user in Group Control.currentDept
: The department the current user is currently logged into in this app (also helpful for saving data)roles
: An array of the roles the user has access to in this department for this app.departments
: An array of the departments user has access to in this app.
Public Functions in CurrentUser
There are a couple of functions that you will use very regularly with this Current User session. They are:
get
. This is the function that is used to get any of the properties listed above (ie$this->user->get('id')
or$this->user->get('currentDept')
). This is the only way you have access to those properties (you can't call$this->user->id
).isAuthenticated
. This function essentially returns a boolean of whether or not the user is currently logged in. And it is described, including with its use case in Auth Core authentication guide
Internal Functions
While all of these functions are technically public, and can be called from anywhere, they are primarily used within Group Control, and there is little if any use case for using them outside of it in a different app.
set
allows you to set the values for various properties, which you are able to get throughget
.roles
does some fancy algorithmic work on roles because of how roles are saved in the session. It just returns$this
.department
this is a setter, which does some manipulation, but mainly sets thedepartments
array.authenticate
logs in the user.toJson
returns all the Current User information as json, so that it can be sent to the client (this is what is sent back in thesession
request of Group Control).
But as you can see, almost none of these are such that you will ever need to use these outside of Group Control itself, and it is highly recommended that you avoid using these functions.