# Class: Login

## vcs.vcm.util.Login

Singleton class used for managing logins to a service. Sofar, only the Planner functionality requires a login

### Members

#### currentUser{Object}

  An object representing the currently logged in user, with groups and permissions

#### projectGroups{Array.<Object>}

  All the groups visible to the currently logged in user

#### projectSettings{Object}

  The settings of the project this map connects to. contains: hasMail, selfRegiser and userInvite values.

#### projectUsers{Array.<Object>}

  All the users, name and userId, visible to the logged in user

#### setupPromise{Promise}

  Once the util has been setup and the connection is ready to receive logins, this promise will resolve

### Methods

#### vcs.vcm.util.Login.getInstance(){vcs.vcm.util.Login}

  Singleton login manager

#### getCurrentUser(){Object}

#### invite(email){Promise}

  invites a user, used for sharing with an unregistered user

  Name | Type | Description
  --- | --- | ---
  `email` | string |

  ##### Throws:

  vcs.vcm.util.InvalidArgument

#### login(email, password){Promise}

  logs the user in

  Name | Type | Description
  --- | --- | ---
  `email` | string |
  `password` | string |

  ##### Throws:

  vcs.vcm.util.InvalidArgument

#### logout(){Promise}

  executes all the beforeLogout functions and logs the user out

#### register(email, password, name){Promise}

  registers a user

  Name | Type | Description
  --- | --- | ---
  `email` | string |
  `password` | string |
  `name` | string | an optional username, by default the user name is taken from the email address before the @

  ##### Throws:

  vcs.vcm.util.InvalidArgument

#### registerHook(type, hook)

  registers an external hook not dependent on a widget

  Name | Type | Description
  --- | --- | ---
  `type` | string | one of 'onLogin', 'onLogout', 'beforeLogout'
  `hook` | function | the callback to be called on the action

  ##### Throws:

  vcs.vcm.util.InvalidArgument

#### requestResetPassword(email){Promise}

  Requests a reset password email from the service for the given email

  Name | Type | Description
  --- | --- | ---
  `email` | string |

  ##### Throws:

  vcs.vcm.util.InvalidArgument

#### resetPassword(password, token){Promise}

  Resets the password of a user, using the new password and the token received in the reset password email.

  Name | Type | Description
  --- | --- | ---
  `password` | string |
  `token` | string |

  ##### Throws:

  vcs.vcm.util.InvalidArgument

#### searchUser(text){Promise}

  Searches for a user with the system

  Name | Type | Description
  --- | --- | ---
  `text` | string |

  Deprecated
    - 3.4
  TODO
    - write search with local project users

#### verifyEmail(token){Promise}

  verifies a users email address per response to a verification email

  Name | Type | Description
  --- | --- | ---
  `token` | string | the token contained in the url of the emails link

  ##### Throws:

  vcs.vcm.util.InvalidArgument