mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
add docs for registering login handler
This commit is contained in:
@@ -315,6 +315,15 @@ Accounts.setAdditionalFindUserOnExternalLogin(({serviceName, serviceData}) => {
|
||||
}
|
||||
})
|
||||
```
|
||||
{% apibox "AccountsServer#registerLoginHandler" %}
|
||||
|
||||
Use this to register your own custom authentication method. This is also used by all of the other inbuilt accounts packages to integrate with the accounts system.
|
||||
|
||||
There can be multiple login handlers that are registered. When a login request is made, it will go through all these handlers to find its own handler.
|
||||
|
||||
The registered handler callback is called with a single argument, the `options` object which comes from the login method. For example, if you want to login with a plaintext password, `options` could be `{ user: { username: <username> }, password: <password> }`,or `{ user: { email: <email> }, password: <password> }`.
|
||||
|
||||
The login handler should return `undefined` if it's not going to handle the login request or else the login result object.
|
||||
|
||||
<h2 id="accounts_rate_limit">Rate Limiting</h2>
|
||||
|
||||
|
||||
@@ -547,19 +547,14 @@ export class AccountsServer extends AccountsCommon {
|
||||
/// LOGIN HANDLERS
|
||||
///
|
||||
|
||||
// The main entry point for auth packages to hook in to login.
|
||||
//
|
||||
// A login handler is a login method which can return `undefined` to
|
||||
// indicate that the login request is not handled by this handler.
|
||||
//
|
||||
// @param name {String} Optional. The service name, used by default
|
||||
// if a specific service name isn't returned in the result.
|
||||
//
|
||||
// @param handler {Function} A function that receives an options object
|
||||
// (as passed as an argument to the `login` method) and returns one of:
|
||||
// - `undefined`, meaning don't handle;
|
||||
// - a login method result object
|
||||
|
||||
/**
|
||||
* @summary Registers a new login handler.
|
||||
* @locus Server
|
||||
* @param {String} [name] The type of login method like oauth, password, etc.
|
||||
* @param {Function} handler A function that receives an options object
|
||||
* (as passed as an argument to the `login` method) and returns one of
|
||||
* `undefined`, meaning don't handle or a login method result object.
|
||||
*/
|
||||
registerLoginHandler(name, handler) {
|
||||
if (! handler) {
|
||||
handler = name;
|
||||
|
||||
Reference in New Issue
Block a user