Skip to content

Commit

Permalink
feat(config, users): add option to diabled sign in up on api side ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil committed Sep 15, 2020
1 parent 8a6e196 commit f5a958f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/defaults/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ module.exports = {
credentials: true,
},
domain: '',
sign: {
in: true, // disable signin
up: true, // disable signup
},
repos: [
{
// generate releases and changelogs list auto /api/core/changelogs /api/core/releases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const UsersSchema = require('../../models/user.schema');
*/
exports.signup = async (req, res) => {
try {
if (!config.sign.up) {
return responses.error(res, 404, 'Error', 'Sign Up actually disabled')();
}
const user = await UserService.create(req.body);
const token = jwt.sign({ userId: user.id }, config.jwt.secret, {
expiresIn: config.jwt.expiresIn,
Expand Down Expand Up @@ -51,6 +54,9 @@ exports.signup = async (req, res) => {
* @param {Function} next - Express next middleware function
*/
exports.signin = async (req, res) => {
if (!config.sign.in) {
return responses.error(res, 404, 'Error', 'Sign In actually disabled')();
}
const user = req.user;
const token = jwt.sign({ userId: user.id }, config.jwt.secret, {
expiresIn: config.jwt.expiresIn,
Expand Down

0 comments on commit f5a958f

Please sign in to comment.