# Class: User

## vertx-auth-common-js/user~ User

#### new User()

  Represents an authenticates User and contains operations to authorise the user.

  Please consult the documentation for a detailed explanation.

  Source:
    - user.js, line 32

### Methods

#### clearCache() → {User}

  The User object will cache any authorities that it knows it has to avoid hitting the underlying auth provider each time. Use this method if you want to clear this cache.
  Source:
    - user.js, line 67

  ##### Returns:

  the User to enable fluent use
  Type
    User

#### isAuthorised(authority, resultHandler) → {User}

  Is the user authorised to

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `authority` | string | the authority - what this really means is determined by the specific implementation. It might represent a permission to access a resource e.g. `printers:printer34` or it might represent authority to a role in a roles based model, e.g. `role:admin`.
  `resultHandler` | function | handler that will be called with an AsyncResult containing the value `true` if the they has the authority or `false` otherwise.

  Source:
    - user.js, line 45

  ##### Returns:

  the User to enable fluent use
  Type
    User

#### principal() → {Object}

  Get the underlying principal for the User. What this actually returns depends on the implementation. For a simple user/password based auth, it's likely to contain a JSON object with the following structure:

           {
             "username", "tim"
           }

  Source:
    - user.js, line 88

  ##### Returns:

  JSON representation of the Principal
  Type
    Object

#### setAuthProvider(authProvider)

  Set the auth provider for the User. This is typically used to reattach a detached User with an AuthProvider, e.g. after it has been deserialized.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `authProvider` | AuthProvider | the AuthProvider - this must be the same type of AuthProvider that originally created the User

  Source:
    - user.js, line 102