authen-express 0.0.2 → 0.0.3
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/lib/index.js +8 -2
- package/package.json +1 -1
- package/src/index.ts +8 -2
package/lib/index.js
CHANGED
@@ -11,8 +11,14 @@ var AuthenticationController = (function () {
|
|
11
11
|
AuthenticationController.prototype.authenticate = function (req, res) {
|
12
12
|
var _this = this;
|
13
13
|
var user = req.body;
|
14
|
-
if (!user.username || user.username.length === 0
|
15
|
-
res.status(401).end('username
|
14
|
+
if (!user.username || user.username.length === 0) {
|
15
|
+
return res.status(401).end('username cannot be empty');
|
16
|
+
}
|
17
|
+
if (!user.password || user.password.length === 0) {
|
18
|
+
return res.status(401).end('password cannot be empty');
|
19
|
+
}
|
20
|
+
if (user.step && user.step > 1 && (!user.passcode || user.passcode.length === 0)) {
|
21
|
+
return res.status(401).end('passcode cannot be empty');
|
16
22
|
}
|
17
23
|
if (this.decrypt) {
|
18
24
|
var p = this.decrypt(user.password);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
@@ -54,8 +54,14 @@ export class AuthenticationController<T extends User> {
|
|
54
54
|
}
|
55
55
|
authenticate(req: Request, res: Response) {
|
56
56
|
const user: T = req.body;
|
57
|
-
if (!user.username || user.username.length === 0
|
58
|
-
res.status(401).end('username
|
57
|
+
if (!user.username || user.username.length === 0) {
|
58
|
+
return res.status(401).end('username cannot be empty');
|
59
|
+
}
|
60
|
+
if (!user.password || user.password.length === 0) {
|
61
|
+
return res.status(401).end('password cannot be empty');
|
62
|
+
}
|
63
|
+
if (user.step && user.step > 1 && (!user.passcode || user.passcode.length === 0)) {
|
64
|
+
return res.status(401).end('passcode cannot be empty');
|
59
65
|
}
|
60
66
|
if (this.decrypt) {
|
61
67
|
const p = this.decrypt(user.password);
|