aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-08-05 17:19:08 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-08-05 17:19:08 +0200
commit99a64bfed25e45547df3045cf249bc895e6f220b (patch)
tree0e8150155d616ee25eac41196bdb6cf7413b376c /server/controllers
parent6606150c49f587bc7eb0ecec4263ce7fbb18bf15 (diff)
downloadPeerTube-99a64bfed25e45547df3045cf249bc895e6f220b.tar.gz
PeerTube-99a64bfed25e45547df3045cf249bc895e6f220b.tar.zst
PeerTube-99a64bfed25e45547df3045cf249bc895e6f220b.zip
Server: allow user to get its informations (/users/me)
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/v1/users.js9
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')
19const router = express.Router() 19const router = express.Router()
20 20
21router.get('/', listUsers) 21router.get('/', listUsers)
22router.get('/me', oAuth.authenticate, getUserInformation)
22 23
23router.post('/', 24router.post('/',
24 oAuth.authenticate, 25 oAuth.authenticate,
@@ -63,6 +64,14 @@ function createUser (req, res, next) {
63 }) 64 })
64} 65}
65 66
67function 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
66function listUsers (req, res, next) { 75function 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)