Skip to content

Commit 1d4dacc

Browse files
committed
added changePasswordEnabled env variable to diable the change password in showcase project
1 parent 828d967 commit 1d4dacc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pages/api/changepassword.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@ import bcrypt from "bcrypt";
33
import { jwtAuth, use } from "../../middleware/middleware";
44
import { changePassword, getUser } from "../../lib/dbfunc";
55

6+
const changePasswordEnabled = process.env.changePasswordEnabled || true;
67
const saltRounds = 10;
78

89
async function handler(req, res) {
910
if (req.method !== "POST") {
1011
res.status(400).send("method not allowed");
1112
return;
1213
}
14+
15+
if (!changePasswordEnabled) {
16+
res.status(401).send("Change Password not allowed");
17+
return;
18+
}
19+
1320
try {
1421
// Run the middleware
1522
await use(req, res, jwtAuth);

0 commit comments

Comments
 (0)