mirror of
https://github.com/strapi/strapi.git
synced 2025-12-16 01:34:23 +00:00
introduction of userObj
Mention of cbx.state.user is missing, added a bit of documentation mentioning it.
This commit is contained in:
parent
88008ea900
commit
1d603d1854
@ -157,6 +157,32 @@ $.ajax({
|
||||
});
|
||||
```
|
||||
|
||||
## User Object In Strapi Context
|
||||
The User object is available to successfully authenticated requests.
|
||||
|
||||
#### Usage
|
||||
- The authenticated `user` object is a property of `ctx.state`.
|
||||
|
||||
|
||||
```js
|
||||
create: async (ctx) => {
|
||||
|
||||
const { _id } = ctx.state.user
|
||||
|
||||
const depositObj = {
|
||||
...ctx.request.body,
|
||||
depositor: _id
|
||||
}
|
||||
|
||||
const data = await strapi.services.deposit.add(depositObj);
|
||||
|
||||
// Send 201 `created`
|
||||
ctx.created(data);
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Email templates
|
||||
|
||||
[See the documentation on GitHub](https://github.com/strapi/strapi/blob/master/packages/strapi-plugin-users-permissions/docs/email-templates.md)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user