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 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 || !user.password || user.password.length === 0) {
15
- res.status(401).end('username and password cannot be empty');
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authen-express",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "authen-express",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
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 || !user.password || user.password.length === 0) {
58
- res.status(401).end('username and password cannot be empty');
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);