Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

docs: Update password.md #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 9 additions & 9 deletions basics/features/password.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ description: '@adminjs/passwords'

# Password

The password feature can be utilized to hash a user's password when editing it's record.
The password feature can be utilized to hash a user's password when editing its record.

Installation
## Installation

```shell
$ yarn add @adminjs/passwords
```

Next step is to add feature option to user resource
Next step is to add the feature option to the user resource:

```javascript
import argon2 from 'argon2';
Expand All @@ -26,23 +26,23 @@ const adminJsOptions = {
{
resource: User,
options: {
//...your regular options go here'
//...your regular options go here
properties: { password: { isVisible: false } },
},
features: [
passwordsFeature({
componentLoader,
properties: {
encryptedPassword: 'password',
password: 'newPassword'
}
password: 'newPassword',
},
hash: argon2.hash,
})
})
]
},
],
//...
}
};
```

In the example above `password` is `User` property which holds encrypted password (we have to make it invisible to keep secure. `newPassword` in `passwordsFeature -> options` properties is a virtual field which keeps entered password and will be hashed before saving.  
In the example above, `password` is the `User` property which holds the encrypted password (we have to make it invisible to keep it secure). `newPassword` in `passwordsFeature` -> `properties` is a virtual field which keeps the entered password and will be hashed before saving.