Class: UserMethods

Defined in: src/methods/user-methods.coffee

Overview

Provides methods to interact with scotties.

Constant Summary

UPDATE_FIELDS_FULL =

CREATE_FIELDS = ['username']

['username', 'description', 'displayName', 'identities', 'primaryEmail', 'profileLinks', 'userImages', 'selectedUserImage', 'emails', 'roles', 'data', 'resourceLimits', 'onboardingState', 'title', 'location', 'needsInit']

Instance Method Summary

Constructor Details

- (void) constructor(models)

Initializes a new instance of the UserMethods class.

Parameters:

  • models (Object) A collection of models that can be used.

Instance Method Details

- (void) all(accountId, options = {}, cb = function() {}) (bound)

Retrieve all users for a specific accountId

- (void) get(userId, options = {}, cb = function() {}) (bound)

Retrieves a user by it's id.

- (void) getByIds(idList = [], options = {}, cb = function() {}) (bound)

Retrieves users by passing a list of id's, which can be string or objectIds

- (void) getByUsernames(accountId, usernames = [], options = {}, cb = function() {}) (bound)

Retrieves users by passing a list of usernames.

Parameters:

  • usernames ([String]) an array of usernames. Case insensitive
  • options (Object) a set of options, which can be null
  • cb (Function) a callback that is invoked after completion of this method.

Options Hash: (options):

  • select (String) the space separated fields to return, which default to all.

- (void) lookup(accountId, q, options = {}, cb = function() {}) (bound)

Returns a list of users who match q. In this version we do a straight user name match.

Parameters:

  • q (String) a search string.
  • options (Object) a set of options, which can be null
  • cb (Function) a callback that is invoked after completion of this method.

Options Hash: (options):

  • limit (Integer) the maximum number of results to return, defaults to 10.
  • sortOrder (String) the sort order in mongodb syntax, which defaults to 'username'.
  • select (String) the space separated fields to return, which default to '_id username displayName selectedUserImage'.

- (void) getByName(accountId, name, options = {}, cb = function() {}) (bound)

- (void) getByPrimaryEmail(accountId, email, options = {}, cb = function() {}) (bound)

- (void) getByNameOrId(accountId, nameOrId, options = {}, cb = function() {}) (bound)

- (void) patch(accountId, usernameOrId, obj = {}, actor, options = {}, cb = function() {}) (bound)

- (void) delete(accountId, usernameOrId, actor, options = {}, cb = function() {}) (bound)

- (void) destroy(accountId, usernameOrId, actor, options = {}, cb = function() {}) (bound)

- (void) setPassword(accountId, usernameOrId, password, actor, options = {}, cb = function() {}) (bound)

- (void) findUserByUsernameOrEmail(accountId, usernameOrEmail, options = {}, cb = function() {}) (bound)

Looks up a user by username or email.

- (void) validateUserByUsernameOrEmail(accountId, usernameOrEmail, password, options = {}, cb = function() {}) (bound)

Looks up the user, if found validates against password. cb(err) in case of non password error. cb(null, user) in case of user not found, password not valid, or valid user

- (void) _hashPassword(password, cb) (bound)

- (void) create(accountId, objs = {}, options = {}, cb = function() {}) (bound)

Creates a new user.

- (void) getOrCreateUserFromProvider(accountId, provider, v1, v2, profile, options = {}, cb = function() {}) (bound)

Gets or creates a user for a given provider/profile combination.

Parameters:

  • provider (String) a provider string like "facebook" or "twitter".
  • v1 (String) the key or access_token, depending on the type of provider
  • v2 (String) the secret or refresh_token, depending on the type of provider
  • profile (Object) The profile as defined here: http://passportjs.org/guide/user-profile.html

- (void) _usernameFromProfile(profile) (bound)

- (void) _displayNameFromProfile(profile) (bound)

- (void) _profileImageFromProfile(profile) (bound)

- (void) addIdentityToUser(userId, provider, v1, v2, profile, options = {}, cb = function() {}) (bound)

Adds an identity to an existing user. In this version, it replaces an existing provider of the same type.

Parameters:

  • userId (String/ObjectId) the id of the user to add this identity to.
  • provider (String) a provider string like "facebook" or "twitter".
  • v1 (String) the key or access_token, depending on the type of provider
  • v2 (String) the secret or refresh_token, depending on the type of provider
  • profile (Object) The profile as defined here: http://passportjs.org/guide/user-profile.html

- (void) removeIdentityFromUser(userId, identityId, options = {}, cb = function() {}) (bound)

- (void) addRoles(userId, roles, options = {}, cb = function() {}) (bound)

- (void) removeRoles(userId, roles, options = {}, cb = function() {}) (bound)

- (void) resetPassword(accountId, email, options = {}, cb = function() {}) (bound)

- (void) resetPasswordToken(accountId, token, password, options = {}, cb = function() {}) (bound)

p0qEeKBoh25031326eefa65c0000000006TWlhZKbLjn

- (void) addEmail(userId, email, isValidated, options = {}, cb = function() {}) (bound)

- (void) removeEmail(userId, email, options = {}, cb = function() {}) (bound)