serverpreconfigured 2.1.4 → 2.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/routes/users.js +5 -5
- package/package.json +2 -2
- package/src/routes/users.ts +5 -5
package/dist/routes/users.js
CHANGED
|
@@ -54,24 +54,24 @@ router.post('/login', (req, res) => __awaiter(void 0, void 0, void 0, function*
|
|
|
54
54
|
password = meta_sanitizer_1.default.queryProtector(req.body.password);
|
|
55
55
|
}
|
|
56
56
|
catch (e) {
|
|
57
|
-
return res.send((0, response_1.JSONResponse)(false, LoginErrorCode.InvalidParams, "Must have 'email' and 'password' params"));
|
|
57
|
+
return res.status(403).send((0, response_1.JSONResponse)(false, LoginErrorCode.InvalidParams, "Must have 'email' and 'password' params"));
|
|
58
58
|
}
|
|
59
59
|
if (password == "" || email == "")
|
|
60
|
-
return res.send((0, response_1.JSONResponse)(false, LoginErrorCode.InvalidParams, "Must have 'email' and 'password' params"));
|
|
60
|
+
return res.status(403).send((0, response_1.JSONResponse)(false, LoginErrorCode.InvalidParams, "Must have 'email' and 'password' params"));
|
|
61
61
|
email = email.toLocaleLowerCase();
|
|
62
62
|
try {
|
|
63
63
|
const checkPass = yield (0, users_1.checkUserPassword)(email, password);
|
|
64
64
|
if (checkPass) {
|
|
65
65
|
(0, auth_3.setUserLogged)(req, email);
|
|
66
|
-
return res.send((0, response_1.JSONResponse)(true, LoginErrorCode.NoError, "Login Ok"));
|
|
66
|
+
return res.status(200).send((0, response_1.JSONResponse)(true, LoginErrorCode.NoError, "Login Ok"));
|
|
67
67
|
}
|
|
68
|
-
return res.send((0, response_1.JSONResponse)(false, LoginErrorCode.InvalidPassword, "Invalid Password"));
|
|
68
|
+
return res.status(403).send((0, response_1.JSONResponse)(false, LoginErrorCode.InvalidPassword, "Invalid Password"));
|
|
69
69
|
}
|
|
70
70
|
catch (e) {
|
|
71
71
|
let more = null;
|
|
72
72
|
if (DEBUG)
|
|
73
73
|
more = e;
|
|
74
|
-
return res.send((0, response_1.JSONResponse)(false, LoginErrorCode.InternalError, "I-Error", more));
|
|
74
|
+
return res.status(500).send((0, response_1.JSONResponse)(false, LoginErrorCode.InternalError, "I-Error", more));
|
|
75
75
|
}
|
|
76
76
|
}));
|
|
77
77
|
router.post('/register', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serverpreconfigured",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"description": "\"Pre-configured server with authentication system and database integration\"",
|
|
5
5
|
"main": "dist/server.js",
|
|
6
6
|
"keywords": [
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@types/cors": "^2.8.12",
|
|
25
25
|
"@types/express": "^4.17.13",
|
|
26
26
|
"@types/express-session": "^1.17.4",
|
|
27
|
-
"argon2": "^0.
|
|
27
|
+
"argon2": "^0.30.3",
|
|
28
28
|
"body-parser": "^1.19.2",
|
|
29
29
|
"colors-cli": "^1.0.28",
|
|
30
30
|
"cors": "^2.8.5",
|
package/src/routes/users.ts
CHANGED
|
@@ -41,23 +41,23 @@ router.post('/login',async (req,res)=>{
|
|
|
41
41
|
email=meta_sanitizer.sanitizeEmail(req.body.email);
|
|
42
42
|
password=meta_sanitizer.queryProtector(req.body.password);
|
|
43
43
|
}catch(e){
|
|
44
|
-
return res.send(JSONResponse(false,LoginErrorCode.InvalidParams,"Must have 'email' and 'password' params"))
|
|
44
|
+
return res.status(403).send(JSONResponse(false,LoginErrorCode.InvalidParams,"Must have 'email' and 'password' params"))
|
|
45
45
|
}
|
|
46
46
|
if(password==""||email=="")
|
|
47
|
-
return res.send(JSONResponse(false,LoginErrorCode.InvalidParams,"Must have 'email' and 'password' params"));
|
|
47
|
+
return res.status(403).send(JSONResponse(false,LoginErrorCode.InvalidParams,"Must have 'email' and 'password' params"));
|
|
48
48
|
email=email.toLocaleLowerCase();
|
|
49
49
|
try{
|
|
50
50
|
const checkPass=await checkUserPassword(email,password);
|
|
51
51
|
if(checkPass){
|
|
52
52
|
setUserLogged(req,email);
|
|
53
|
-
return res.send(JSONResponse(true,LoginErrorCode.NoError,"Login Ok"));
|
|
53
|
+
return res.status(200).send(JSONResponse(true,LoginErrorCode.NoError,"Login Ok"));
|
|
54
54
|
}
|
|
55
|
-
return res.send(JSONResponse(false,LoginErrorCode.InvalidPassword,"Invalid Password"));
|
|
55
|
+
return res.status(403).send(JSONResponse(false,LoginErrorCode.InvalidPassword,"Invalid Password"));
|
|
56
56
|
}catch(e){
|
|
57
57
|
let more=null;
|
|
58
58
|
if(DEBUG)
|
|
59
59
|
more=e;
|
|
60
|
-
return res.send(JSONResponse(false,LoginErrorCode.InternalError,"I-Error",more));
|
|
60
|
+
return res.status(500).send(JSONResponse(false,LoginErrorCode.InternalError,"I-Error",more));
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
});
|