Creating a strategy
A strategy authenticates a user from information in an incoming request. A strategy is made up of the following:
The
authenticate function is passed the following arguments:
authenticate returns an AuthStrategyResult:
Example strategy
ImportAuthStrategy from frogbot to type your strategy, then add it to an auth collection’s strategies array.
Return { user: null } when the credentials are missing or do not identify a user. Otherwise, return the user document with its collection slug. You can also return responseHeaders: new Headers(...) when canSetHeaders is true.
This example uses a per-user code as a credential. Keep it secret and send it only over HTTPS. With the local strategy disabled, custom user fields such as email may be nullable; return the complete document rather than requiring an email address.