Skip to content

Commit

Permalink
Merge branch 'main' into ds-fix-setup-clerk
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Jul 22, 2022
2 parents 1e3a9f3 + b562305 commit 14913b0
Show file tree
Hide file tree
Showing 20 changed files with 736 additions and 245 deletions.
41 changes: 41 additions & 0 deletions docs/docs/auth/dbauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,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:
Expand All @@ -123,6 +133,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`:
Expand Down Expand Up @@ -167,6 +187,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:
Expand All @@ -177,6 +207,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.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ yarn rw setup ui --help
## Testing with Jest

It'd be hard to scale from side project to startup without a few tests.
Redwood fully integrates Jest with the front and the backends and makes it easy to keep your whole app covered by generating test files with all your components and services:
Redwood fully integrates Jest with both the front and backends, and makes it easy to keep your whole app covered by generating test files with all your components and services:

```
yarn rw test
Expand Down
5 changes: 3 additions & 2 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"runner": "@nrwl/nx-cloud",
"options": {
"cacheableOperations": [
"test",
"build"
],
"parallel": 5
"parallel": 5,
"accessToken": "ODMxYWQ1ZjgtMTJhNi00M2Q1LTg1YTAtNTk3NjFkNzNmZjk0fHJlYWQ="
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@
"@babel/preset-react": "7.16.7",
"@babel/preset-typescript": "7.16.7",
"@babel/runtime-corejs3": "7.16.7",
"@nrwl/nx-cloud": "14.2.0",
"@playwright/test": "1.23.4",
"@testing-library/jest-dom": "5.16.4",
"@testing-library/react": "12.1.5",
"@testing-library/react-hooks": "8.0.1",
"@testing-library/user-event": "14.2.6",
"@testing-library/user-event": "14.3.0",
"@types/fs-extra": "9.0.13",
"@types/jest": "27.5.2",
"@types/jscodeshift": "0.11.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@prisma/client": "3.15.2",
"base64url": "3.0.1",
"core-js": "3.23.5",
"cross-undici-fetch": "0.4.13",
"cross-undici-fetch": "0.4.14",
"crypto-js": "4.1.1",
"humanize-string": "2.1.0",
"jsonwebtoken": "8.5.1",
Expand Down
Loading

0 comments on commit 14913b0

Please sign in to comment.