Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the whoami smart action and an exemple to extend the API
- Loading branch information
Showing
5 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const express = require('express'); | ||
const router = express.Router(); | ||
const Liana = require('forest-express-sequelize'); | ||
|
||
router.delete('/companies/:companyId', Liana.ensureAuthenticated, | ||
(req, res, next) => { | ||
if (req.user.data.teams.indexOf('Management') > -1) { | ||
next(); | ||
} else { | ||
res.status(403).send('Sorry, you\'re now allowed to delete a company. Ask someone in the Management team.'); | ||
} | ||
}); | ||
|
||
module.exports = router; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const express = require('express'); | ||
const router = express.Router(); | ||
const Liana = require('forest-express-sequelize'); | ||
|
||
router.get('/whoami', Liana.ensureAuthenticated, (req, res) => { | ||
res.send({ success: `You are ${req.user.data.first_name} ${req.user.data.last_name}.` }); | ||
}); | ||
|
||
module.exports = router; |