currentUser - Mura Docs v7.0

currentUser

The currentUser object is a wrapper of the sessionUserFacade, and is a subscope object of the Mura Scope. Under the hood, Mura allows for access to the user bean/object attributes, as well as some special session-specific data, such as whether the current user is logged in, whether the current user is a super user or admin user, etc.

Syntax

The following examples illustrate how to "get" and/or "set" various attributes of the sessionUserFacade bean/object. Use whichever syntax feels best to you.

Getters

m.currentUser('attributeName')
m.currentUser().get('attributeName')
m.currentUser().get{AttributeName}()
m.currentUser().getValue('attributeName')

Setters

m.currentUser('attributeName', 'someValue')
m.currentUser().set('attributeName', 'someValue')
m.currentUser().set{AttributeName}('someValue')
m.currentUser().setValue('attributeName', 'someValue')

Returns

A populated sessionUserFacade bean/object.

Usage

Use this scope to access information about the user of the site in the current request.

Attributes

See the User Bean section for details on available attributes.

Helper Methods

In addition to the user bean/object's helper methods, the currentUser object has some special helper methods of its own.

isLoggedIn()

Returns true if the user is logged in. Otherwise, returns false if the user is logged out.

<cfif m.currentUser().isLoggedIn()>
<!--- User IS logged in --->
<h3>Hello, #esapiEncode('html', m.currentUser('fname'))#!</h3>
<cfelse>
<!--- Use is NOT logged in --->
  <h3>Who are you?</h3>
</cfif>

isSuperUser()

Returns true if the user is a "super" user. Otherwise, returns false.

<cfif m.currentUser().isSuperUser()>
<!--- User IS a 'super' user --->
<cfelse>
<!--- Use is NOT a 'super' user --->
</cfif>

isAdminUser()

Returns true fi the user is an "admin" user. Otherwise, returns false.

<cfif m.currentUser().isAdminUser()>
<!--- User IS an 'admin' user --->
<cfelse>
<!--- Use is NOT an 'admin' user --->
</cfif>