mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Move the loginWithPasswordAnd2faCode to the accounts-password package
This commit is contained in:
@@ -72,28 +72,3 @@ Accounts.enableUser2fa = (code, callback) => {
|
||||
Accounts.disableUser2fa = callback => {
|
||||
Accounts.connection.call('disableUser2fa', callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Log the user in with a password and token.
|
||||
* @locus Client
|
||||
* @param {Object | String} selector
|
||||
* Either a string interpreted as a username or an email; or an object with a
|
||||
* single key: `email`, `username` or `id`. Username or email match in a case
|
||||
* insensitive manner.
|
||||
* @param {String} password The user's password.
|
||||
* @param {String} token Token provide by the user's authenticator app.
|
||||
* @param {Function} [callback] Optional callback.
|
||||
* Called with no arguments on success, or with a single `Error` argument
|
||||
* on failure.
|
||||
* @importFromPackage meteor
|
||||
*/
|
||||
|
||||
Meteor.loginWithPasswordAnd2faCode = (selector, password, code, callback) => {
|
||||
if (code == null || typeof code !== 'string' || !code) {
|
||||
throw new Meteor.Error(
|
||||
400,
|
||||
'token is required to use loginWithPasswordAnd2faCode and must be a string'
|
||||
);
|
||||
}
|
||||
return Accounts._internalLoginWithPassword({ selector, password, code, callback });
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ const reportError = (error, callback) => {
|
||||
};
|
||||
|
||||
|
||||
Accounts._internalLoginWithPassword = ({ selector, password, code, callback }) => {
|
||||
const internalLoginWithPassword = ({ selector, password, code, callback }) => {
|
||||
if (typeof selector === 'string')
|
||||
if (!selector.includes('@')) selector = { username: selector };
|
||||
else selector = { email: selector };
|
||||
@@ -56,7 +56,7 @@ Accounts._internalLoginWithPassword = ({ selector, password, code, callback }) =
|
||||
* @importFromPackage meteor
|
||||
*/
|
||||
Meteor.loginWithPassword = (selector, password, callback) => {
|
||||
return Accounts._internalLoginWithPassword({ selector, password, callback });
|
||||
return internalLoginWithPassword({ selector, password, callback });
|
||||
};
|
||||
|
||||
Accounts._hashPassword = password => ({
|
||||
@@ -64,6 +64,33 @@ Accounts._hashPassword = password => ({
|
||||
algorithm: "sha-256"
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @summary Log the user in with a password and token.
|
||||
* @locus Client
|
||||
* @param {Object | String} selector
|
||||
* Either a string interpreted as a username or an email; or an object with a
|
||||
* single key: `email`, `username` or `id`. Username or email match in a case
|
||||
* insensitive manner.
|
||||
* @param {String} password The user's password.
|
||||
* @param {String} token Token provide by the user's authenticator app.
|
||||
* @param {Function} [callback] Optional callback.
|
||||
* Called with no arguments on success, or with a single `Error` argument
|
||||
* on failure.
|
||||
* @importFromPackage meteor
|
||||
*/
|
||||
|
||||
Meteor.loginWithPasswordAnd2faCode = (selector, password, code, callback) => {
|
||||
if (code == null || typeof code !== 'string' || !code) {
|
||||
throw new Meteor.Error(
|
||||
400,
|
||||
'token is required to use loginWithPasswordAnd2faCode and must be a string'
|
||||
);
|
||||
}
|
||||
return internalLoginWithPassword({ selector, password, code, callback });
|
||||
};
|
||||
|
||||
|
||||
// Attempt to log in as a new user.
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user