Skip to content

Implement Accounts.has2faEnabled #139

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ Registers a callback to be called when login fails

- callback

#### `Accounts.has2faEnabled(callback)`

Checks if the current user has 2fa enabled, via callback; cf. [the meteor docs](https://docs.meteor.com/packages/accounts-2fa#Accounts-has2faEnabled)

**Arguments**

- callback - Called with an error on the first argument, e.g. if the user is currently not logged in, and a boolean result on the second argument, if the user has 2fa enabled.

#### `Accounts._hashPassword(plaintext)` => `{algorithm:"sha-256", digest:"..."}`

Hashes a password using the sha-256 algorithm. Returns an object formatted for use in accounts calls. You can access the raw hashed string using the digest property.
Expand Down
4 changes: 4 additions & 0 deletions src/user/Accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ class AccountsPassword {
onLoginFailure = (cb) => {
Data.on('onLoginFailure', cb);
};

has2faEnabled = (callback = () => {}) => {
call('has2faEnabled', callback);
};
}

export default new AccountsPassword();