Skip to content

Service Calls

The feathers-authentication-management service methods can be called using various ways. These can be external calls from the client as well as internal calls within the server. On client side, you can use the Feathers client, plain and simple HTTP requests, or any other request library your frontend framework provides.

The service may be called using

  • Direct Feathers service calls,
  • HTTP requests on the Feathers API,
  • Provided service wrappers (see last section).

Comparison of the different service calls

There are three ways of calling a method:

  1. Main service as AuthenticationManagementService with create and action
  2. Separate services (e.g. SendResetPwdService) with create
  3. Main service as AuthenticationManagementService with custom method (e.g. sendResetPassword)
js
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service("auth-management").create({
  action: "sendResetPwd",
  value: {
    email: "me@example.com",
  },
});
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service("auth-management").create({
  action: "sendResetPwd",
  value: {
    email: "me@example.com",
  },
});

checkUnique

Checks if the properties are unique in the users items.

js
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'checkUnique',
  value: identifyUser, // e. g. {email: 'a@a.com'} or  {username: 'jane'}. Props with null or undefined are ignored.
  ownId, // Excludes user with ownId from the search
  meta: { noErrMsg } // if return an error.message if not unique
}
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'checkUnique',
  value: identifyUser, // e. g. {email: 'a@a.com'} or  {username: 'jane'}. Props with null or undefined are ignored.
  ownId, // Excludes user with ownId from the search
  meta: { noErrMsg } // if return an error.message if not unique
}

Returns null if the properties are unique (= already existing) in the users items. Otherwise rejects with BadRequest.

identityChange

Changes the communication address of a user, e. g. the e-mail address or a phone number.

js
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'identityChange',
  value: {
    user: identifyUser, // identify user, e.g. {email: 'a@a.com'}. See options.identifyUserProps.
    password, // current password for verification
    changes, // {email: 'a@a.com'} or {email: 'a@a.com', cellphone: '+1-800-555-1212'}
  },
  notifierOptions: {}, // optional - an object passed to notifier function
}
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'identityChange',
  value: {
    user: identifyUser, // identify user, e.g. {email: 'a@a.com'}. See options.identifyUserProps.
    password, // current password for verification
    changes, // {email: 'a@a.com'} or {email: 'a@a.com', cellphone: '+1-800-555-1212'}
  },
  notifierOptions: {}, // optional - an object passed to notifier function
}

Returns the user object or rejects with BadRequest.

passwordChange

Changes the password of a user.

js
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'passwordChange',
  value: {
    user: identifyUser, // identify user, e.g. {email: 'a@a.com'}. See options.identifyUserProps.
    oldPassword, // old password for verification
    password, // new password
  },
  notifierOptions: {} // optional - an object passed to notifier function
}
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'passwordChange',
  value: {
    user: identifyUser, // identify user, e.g. {email: 'a@a.com'}. See options.identifyUserProps.
    oldPassword, // old password for verification
    password, // new password
  },
  notifierOptions: {} // optional - an object passed to notifier function
}

Returns the user object or rejects with BadRequest.

resendVerifySignup

Recreates a long and/or short verification token, stores it to the user item, and triggers the notifier function to send the token to the user.

js
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'resendVerifySignup',
  value: identifyUser, // {email}, {token: verifyToken}
  notifierOptions: {}, // optional - an object passed to notifier function
}
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'resendVerifySignup',
  value: identifyUser, // {email}, {token: verifyToken}
  notifierOptions: {}, // optional - an object passed to notifier function
}

Returns the user object or rejects with BadRequest.

resetPwdLong

Stores a new password. Requires a valid long resetToken.

js
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'resetPwdLong',
  value: {
    token, // compares to resetToken
    password, // new password
  },
  notifierOptions: {}, // optional - an object passed to notifier function
}
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'resetPwdLong',
  value: {
    token, // compares to resetToken
    password, // new password
  },
  notifierOptions: {}, // optional - an object passed to notifier function
}

Returns the user object or rejects with BadRequest.

resetPwdShort

Stores a new password. Requires a valid short resetShortToken and a property of the user object to identify the user.

js
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'resetPwdShort',
  value: {
    user: identifyUser, // identify user, e.g. {email: 'a@a.com'}. See options.identifyUserProps.
    token, // compares to .resetShortToken
    password, // new password
  },
  notifierOptions: {}, // optional - an object passed to notifier function
}
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'resetPwdShort',
  value: {
    user: identifyUser, // identify user, e.g. {email: 'a@a.com'}. See options.identifyUserProps.
    token, // compares to .resetShortToken
    password, // new password
  },
  notifierOptions: {}, // optional - an object passed to notifier function
}

Returns the user object or rejects with BadRequest.

sendResetPwd

Creates a short and/or long password reset token, stores it to the user item, and triggers the notifier function to send the token to the user.

js
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'sendResetPwd',
  value: identifyUser, // {email}, {token: verifyToken}
  notifierOptions: {}, // optional - an object passed to notifier function
}
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'sendResetPwd',
  value: identifyUser, // {email}, {token: verifyToken}
  notifierOptions: {}, // optional - an object passed to notifier function
}

Returns the user object or rejects with BadRequest.

verifySignupLong

Verifies a given long verification token.

js
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'verifySignupLong',
  value: verifyToken, // compares to .verifyToken
  notifierOptions: {}, // optional - an object passed to notifier function
}
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'verifySignupLong',
  value: verifyToken, // compares to .verifyToken
  notifierOptions: {}, // optional - an object passed to notifier function
}

Returns the user object or rejects with BadRequest.

verifySignupShort

Verifies a given short verification token.

js
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'verifySignupShort',
  value: {
    user, // identify user, e.g. {email: 'a@a.com'}. See options.identifyUserProps.
    token, // compares to .verifyShortToken
  },
  notifierOptions: {}, // optional - an object passed to notifier function
}
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'verifySignupShort',
  value: {
    user, // identify user, e.g. {email: 'a@a.com'}. See options.identifyUserProps.
    token, // compares to .verifyShortToken
  },
  notifierOptions: {}, // optional - an object passed to notifier function
}

Returns the user object or rejects with BadRequest.

verifySignupSetPasswordLong

This is a combination of verifySignupLong and resetPwdLong: Verifies a given long verification token and stores the new password.

js
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'verifySignupSetPasswordLong',
  value: {
    token, // compares to .verifyToken
    password, // new password
  },
  notifierOptions: {}, // optional - an object passed to notifier function
}
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'verifySignupSetPasswordLong',
  value: {
    token, // compares to .verifyToken
    password, // new password
  },
  notifierOptions: {}, // optional - an object passed to notifier function
}

Returns the user object or rejects with BadRequest.

verifySignupSetPasswordShort

This is a combination of verifySignupShort and resetPwdShort: Verifies a given short verification token and stores the new password.

js
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'verifySignupSetPasswordShort',
  value: {
    user, // identify user, e.g. {email: 'a@a.com'}. See options.identifyUserProps.
    token, // compares to .verifyShortToken
    password, // new password
  },
  notifierOptions: {}, // optional - an object passed to notifier function
}
// const { AuthenticationManagementService } = require('feathers-authentication-management');
// app.use('auth-management', new AuthenticationManagementService(app, options));

app.service('auth-management').create({
  action: 'verifySignupSetPasswordShort',
  value: {
    user, // identify user, e.g. {email: 'a@a.com'}. See options.identifyUserProps.
    token, // compares to .verifyShortToken
    password, // new password
  },
  notifierOptions: {}, // optional - an object passed to notifier function
}

Returns the user object or rejects with BadRequest.

Released under the MIT License.