User

User class handles the authenticated user

Returns: Object | Object - User details

hasPermission(permission)⇒ Boolean

Check if current user has a specific access permission

Available permissions are (more permissions may come in the future as the need for granularity grows):

Role with permissions (Permissions are inherited down the line, which means that an `AdminUser` also has `group/powerUser` and `group/user` etc)
ReadOnly:
- writer:access
- writer:group/readOnly
User:
- writer:group/user
PowerUser:
- writer:group/powerUser
AdminUser:
- writer:group/admin

Returns: Boolean - exists

Parameters

Param
Type
Description

permission

String

Required - Permission to look for in users permissions

Example

if (writer.api.user.hasPermission('writer:group/admin')) {
   // Do stuff
}

hasUserPermission()⇒ boolean

Convinience method to find out if current user is a "user"

Returns: boolean - If user is "user"

Example

if (writer.api.user.hasUserPermission()) {
   // Do stuff
}

hasPowerUserPermission()⇒ boolean

Convinience method to find out if current user is a "power user"

Returns: boolean - If user is "power user"

Example

if (writer.api.user.hasPowerUserPermission()) {
   // Do stuff
}

hasAdminPermission()⇒ boolean

Convinience method to find out if current user is an "admin user"

Returns: boolean - If user is "admin"

Example

if (writer.api.user.hasAdminPermission()) {
   // Do stuff
}

getUserInfo()⇒ Promise.<{given_name:String, family_name:String, email:String, picture:String, org:String, unit: String, permissions: Array.<string>}>

Get current logged in user info object. Object contains info about current user, organisation, selected unit and permissions

Returns: Promise.<{given_name:String, family_name:String, email:String, picture:String, org:String, unit: String, permissions: Array.<string>}> - User details

logout()⇒ void

Logout current user and reload page to trigger new login flow

Last updated