Skip to content

Commit

Permalink
docs:Less service attribute (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
bugss authored and popomore committed Jun 1, 2017
1 parent 15fa82a commit a1fd088
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,35 @@ $ npm i egg-userservice

- `ctx.user`: current user data
- `ctx.userId`: the user id of current user
- `app.config.userservice.service.getUser(ctx)`:
- `app.config.userservice.service.getUserId(ctx)`:



## Configuration

Add your userservice configurations to `config/config.default.js`

```js
exports.userservice = {
* getUser(ctx) {
// Retrieve your user data from cookie, redis, db, whatever
// For common web applications using cookie, you may get session id with ctx.cookies
},

getUserId(ctx) {
// The way to get userId
// eg. return ctx.user.userId
service: {
* getUser(ctx) {
// Retrieve your user data from cookie, redis, db, whatever
// For common web applications using cookie, you may get session id with ctx.cookies
},

getUserId(ctx) {
// The way to get userId
// eg. return ctx.user.userId
}
}
}
```





## For complicated applications

The way your application retrieving user data can be complicated, it may be very weird
Expand Down

0 comments on commit a1fd088

Please sign in to comment.