From 7a81625c402aeb83a76e11de1533c1220966ab89 Mon Sep 17 00:00:00 2001 From: Adrian Obelmejias Date: Fri, 4 Mar 2016 21:55:18 -0500 Subject: [PATCH] Add documentation for authentication route --- src/controllers/auth.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/controllers/auth.js b/src/controllers/auth.js index 3a66471..0089a3b 100644 --- a/src/controllers/auth.js +++ b/src/controllers/auth.js @@ -5,6 +5,37 @@ import config from '../../config/config' const router = new Router({ prefix: '/auth' }) + +/** + * @api {post} /auth Authenticate user + * @apiVersion 1.0.0 + * @apiName AuthUser + * @apiGroup Auth + * + * @apiParam {String} email User email. + * @apiParam {String} password User password. + * + * @apiSuccess {String} firstname Firstname of the User. + * @apiSuccess {String} lastname Lastname of the User. + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * { + * "user": { + * "username": "johndoe" + * }, + * "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ" + * } + * + * @apiError UserNotFound The id of the User was not found. + * + * @apiErrorExample {json} Error-Response: + * HTTP/1.1 401 Unauthorized + * { + * "status": 401, + * "error": "Unauthorized" + * } + */ router.post('/', async (ctx, next) => passport.authenticate('local', (user) => { if (!user) {