mirror of
https://github.com/plankanban/planka.git
synced 2025-12-19 17:23:27 +03:00
Initial commit
This commit is contained in:
36
server/api/responses/unauthorized.js
Executable file
36
server/api/responses/unauthorized.js
Executable file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* unauthorized.js
|
||||
*
|
||||
* A custom response.
|
||||
*
|
||||
* Example usage:
|
||||
* ```
|
||||
* return res.unauthorized();
|
||||
* // -or-
|
||||
* return res.unauthorized(optionalData);
|
||||
* ```
|
||||
*
|
||||
* Or with actions2:
|
||||
* ```
|
||||
* exits: {
|
||||
* somethingHappened: {
|
||||
* responseType: 'unauthorized'
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* ```
|
||||
* throw 'somethingHappened';
|
||||
* // -or-
|
||||
* throw { somethingHappened: optionalData }
|
||||
* ```
|
||||
*/
|
||||
|
||||
module.exports = function unauthorized(message) {
|
||||
const { res } = this;
|
||||
|
||||
return res.status(401).json({
|
||||
code: 'E_UNAUTHORIZED',
|
||||
message
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user