diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-08-05 17:19:08 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-08-05 17:19:08 +0200 |
commit | 99a64bfed25e45547df3045cf249bc895e6f220b (patch) | |
tree | 0e8150155d616ee25eac41196bdb6cf7413b376c /server/controllers/api/v1 | |
parent | 6606150c49f587bc7eb0ecec4263ce7fbb18bf15 (diff) | |
download | PeerTube-99a64bfed25e45547df3045cf249bc895e6f220b.tar.gz PeerTube-99a64bfed25e45547df3045cf249bc895e6f220b.tar.zst PeerTube-99a64bfed25e45547df3045cf249bc895e6f220b.zip |
Server: allow user to get its informations (/users/me)
Diffstat (limited to 'server/controllers/api/v1')
-rw-r--r-- | server/controllers/api/v1/users.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/server/controllers/api/v1/users.js b/server/controllers/api/v1/users.js index fdbcc3ff5..d831a0de6 100644 --- a/server/controllers/api/v1/users.js +++ b/server/controllers/api/v1/users.js | |||
@@ -19,6 +19,7 @@ const Video = mongoose.model('Video') | |||
19 | const router = express.Router() | 19 | const router = express.Router() |
20 | 20 | ||
21 | router.get('/', listUsers) | 21 | router.get('/', listUsers) |
22 | router.get('/me', oAuth.authenticate, getUserInformation) | ||
22 | 23 | ||
23 | router.post('/', | 24 | router.post('/', |
24 | oAuth.authenticate, | 25 | oAuth.authenticate, |
@@ -63,6 +64,14 @@ function createUser (req, res, next) { | |||
63 | }) | 64 | }) |
64 | } | 65 | } |
65 | 66 | ||
67 | function getUserInformation (req, res, next) { | ||
68 | User.loadByUsername(res.locals.oauth.token.user.username, function (err, user) { | ||
69 | if (err) return next(err) | ||
70 | |||
71 | return res.json(user.toFormatedJSON()) | ||
72 | }) | ||
73 | } | ||
74 | |||
66 | function listUsers (req, res, next) { | 75 | function listUsers (req, res, next) { |
67 | User.list(function (err, usersList) { | 76 | User.list(function (err, usersList) { |
68 | if (err) return next(err) | 77 | if (err) return next(err) |