All about user login
Not runnable at the moment
This commit is contained in:
parent
fbb8f5799e
commit
d79bbad575
49 changed files with 1554 additions and 686 deletions
44
routes/rest/users.js
Normal file
44
routes/rest/users.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
'use strict';
|
||||
|
||||
const passport = require('../../lib/passport');
|
||||
const _ = require('../../lib/translate')._;
|
||||
const users = require('../../models/users');
|
||||
const interoperableErrors = require('../../shared/interoperable-errors');
|
||||
|
||||
const router = require('../../lib/router-async').create();
|
||||
|
||||
|
||||
router.getAsync('/users/:userId', passport.loggedIn, async (req, res) => {
|
||||
const user = await users.getById(req.params.userId);
|
||||
user.hash = users.hash(user);
|
||||
return res.json(user);
|
||||
});
|
||||
|
||||
router.postAsync('/users', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
await users.create(req.body);
|
||||
return res.json();
|
||||
});
|
||||
|
||||
router.putAsync('/users/:userId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
const user = req.body;
|
||||
user.id = parseInt(req.params.userId);
|
||||
|
||||
await users.updateWithConsistencyCheck(user);
|
||||
return res.json();
|
||||
});
|
||||
|
||||
router.deleteAsync('/users/:userId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
await users.remove(req.params.userId);
|
||||
return res.json();
|
||||
});
|
||||
|
||||
router.postAsync('/users-validate', passport.loggedIn, async (req, res) => {
|
||||
return res.json(await users.serverValidate(req.body));
|
||||
});
|
||||
|
||||
router.postAsync('/users-table', passport.loggedIn, async (req, res) => {
|
||||
return res.json(await users.listDTAjax(req.body));
|
||||
});
|
||||
|
||||
|
||||
module.exports = router;
|
Loading…
Add table
Add a link
Reference in a new issue