56 lines
1.9 KiB
JavaScript
56 lines
1.9 KiB
JavaScript
module.exports = function (app) {
|
|
const router = require('express').Router(),
|
|
userCtl = require('../controllers/user');
|
|
|
|
// On routes that end in /users
|
|
router.route('/').post(userCtl.createUser_post);
|
|
|
|
// On routes that end in /users/:user_id
|
|
router.route('/:userId')
|
|
.get(userCtl.getUser_get)
|
|
.put(userCtl.updateUser_put)
|
|
.delete(userCtl.deleteUser)
|
|
|
|
/**
|
|
* @api {post} /users/login Login to AgMission server
|
|
* @apiVersion 1.2.1
|
|
* @apiName PostUsersLogin
|
|
* @apiGroup Users
|
|
* @apiDescription Login to AgMission Server. The returned token can be used for other API calls. For accounts used in aircrafts,
|
|
* user should login at the beginning of each work session such as beginning of the day to make sure the token is still valid or not.
|
|
* @apiParam {String} username The account's username
|
|
* @apiParam {String} password The account's password
|
|
* @apiParamExample {json} Request-Example:
|
|
* {
|
|
* "username": "me@mail.com", "password": "notell"
|
|
* }
|
|
* @apiSuccess {String} token Authorization token
|
|
* @apiSuccessExample {json} Success
|
|
* HTTP/1.1 200 OK
|
|
* {
|
|
* "token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI1YWQ1Zjc4NWE5OWEzZjFkOWZjMmM5ZDAiLCJ1dCI6OSwiaWF0IjoxNTIzOTk0NjM1fQ.H_FRXwFiq33Pt9ZSF2LejWfrIG8ijb1xgFEl2Y7affT"
|
|
* }
|
|
* @apiuse WrongCredentialError
|
|
* @apiuse InActiveAccountError
|
|
*/
|
|
router.post('/login', userCtl.login_post);
|
|
|
|
router.route('/exists').post(userCtl.isUserNameExists_post);
|
|
|
|
router.route('/search').post(userCtl.search_post);
|
|
|
|
router.post('/clearTempData', userCtl.clearTempData_post);
|
|
|
|
router.post('/updateLang', userCtl.setUserLanguage_post);
|
|
|
|
router.post('/getUserDetail', userCtl.getUserDetail_post);
|
|
|
|
router.post('/mailPwdReset', userCtl.mailPwdReset_post);
|
|
|
|
router.get('/resetPassword/:id/:token', userCtl.getResetPwdToken_get);
|
|
|
|
router.post('/resetPassword', userCtl.resetPassword);
|
|
|
|
app.use('/api/users', router);
|
|
};
|