From b1854eab6caa9f6ffb954e670e531061c772fda7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sowa?= Date: Sat, 16 Jul 2022 17:49:55 +0200 Subject: [PATCH] Update configuration docs --- docs/docs/auth/dbauth.md | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/docs/docs/auth/dbauth.md b/docs/docs/auth/dbauth.md index 3061b08062ea..b69a3ebd92ea 100644 --- a/docs/docs/auth/dbauth.md +++ b/docs/docs/auth/dbauth.md @@ -97,6 +97,16 @@ If you'd rather create your own, you might want to start from the generated page Almost all config for dbAuth lives in `api/src/functions/auth.js` in the object you give to the `DbAuthHandler` initialization. The comments above each key will explain what goes where. Here's an overview of the more important options: +### login.enabled + +Allow users to call login. Defaults to true. Needs to be explicitly set to false to disable the flow. + +```jsx +login: { + enabled: false +} +``` + ### login.handler() If you want to do something other than immediately let a user log in if their username/password is correct, you can add additional logic in `login.handler()`. For example, if a user's credentials are correct, but they haven't verified their email address yet, you can throw an error in this function with the appropriate message and then display it to the user. If the login should proceed, simply return the user that was passed as the only argument to the function: @@ -113,6 +123,16 @@ login: { } ``` +### signup.enabled + +Allow users to sign up. Defaults to true. Needs to be explicitly set to false to disable the flow. + +```jsx +signup: { + enabled: false +} +``` + ### signup.handler() This function should contain the code needed to actually create a user in your database. You will receive a single argument which is an object with all of the fields necessary to create the user (`username`, `hashedPassword` and `salt`) as well as any additional fields you included in your signup form in an object called `userAttributes`: @@ -157,6 +177,16 @@ const onSubmit = async (data) => { } ``` +### forgotPassword.enabled + +Allow users to request a new password via a call to `forgotPassword`. Defaults to true. Needs to be explicitly set to false to disable the flow. +When disabling this flow you probably want to disable `resetPassword` as well. + +```jsx +forgotPassword: { + enabled: false +} +``` ### forgotPassword.handler() This handler is invoked if a user is found with the username/email that they submitted on the Forgot Password page, and that user will be passed as an argument. Inside this function is where you'll send the user a link to reset their password—via an email is most common. The link will, by default, look like: @@ -167,6 +197,17 @@ If you changed the path to the Reset Password page in your routes you'll need to https://example.com/reset-password?resetKey=${user.resetKey} +### resetPassword.enabled + +Allow users to reset their password via a code from a call to `forgotPassword`. Defaults to true. Needs to be explicitly set to false to disable the flow. +When disabling this flow you probably want to disable `forgotPassword` as well. + +```jsx +resetPassword: { + enabled: false +} +``` + ### resetPassword.handler() This handler is invoked after the password has been successfully changed in the database. Returning something truthy (like `return user`) will automatically log the user in after their password is changed. If you'd like to return them to the login page and make them log in manually, `return false` and redirect the user in the Reset Password page.