Skip to content

Commit

Permalink
Merge pull request #1833 from strapi/feature/add-allowedfields
Browse files Browse the repository at this point in the history
Add `allowedfields` to Users & Permissions configuration
  • Loading branch information
meganelacheny authored Aug 30, 2023
2 parents 1b8ea69 + 1e18d25 commit 555ffec
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion docusaurus/docs/dev-docs/plugins/users-permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,57 @@ Setting JWT expiry for more than 30 days is **not recommended** due to security

### Registration

Creates a new user in the database with a default role as 'registered'.
#### Configuration

If you have added any additional fields to your user model that need to be accepted on registration, they need to be added to the list of allowed fields in the `register` configuration option, otherwise they will not be accepted.

For example, if you have added a field called "nickname" that you wish to accept from the API on user registration:

<Tabs groupId="js-ts">

<TabItem value="javascript" label="JavaScript">

```js title="./config/plugins.js"
module.exports = ({ env }) => ({
// ...
"users-permissions": {
config: {
register: {
allowedFields: ["nickname"],
},
},
},
// ...
});
```

</TabItem>

<TabItem value="typescript" label="TypeScript">

```ts title="./config/plugins.ts"
export default ({ env }) => ({
// ...
"users-permissions": {
config: {
register: {
allowedFields: ["nickname"],
},
},
},
// ...
});
```

</TabItem>

</Tabs>


#### Usage

Creates a new user in the database with a default role as 'registered'.

```js
import axios from 'axios';

Expand Down

1 comment on commit 555ffec

@vercel
Copy link

@vercel vercel bot commented on 555ffec Aug 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

documentation – ./

documentation-strapijs.vercel.app
docs-vercel-v4.strapi.io
documentation-git-main-strapijs.vercel.app

Please sign in to comment.