login-plus 1.9.2 → 1.9.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/README.md CHANGED
@@ -5,6 +5,7 @@ login service for express
5
5
  [![downloads](https://img.shields.io/npm/dm/login-plus.svg)](https://npmjs.org/package/login-plus)
6
6
  [![build](https://github.com/codenautas/login-plus/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/codenautas/login-plus/actions/workflows/build-and-test.yml)
7
7
  [![coverage](https://img.shields.io/coveralls/codenautas/login-plus/master.svg)](https://coveralls.io/r/codenautas/login-plus)
8
+ [![sonar](https://sonarcloud.io/api/project_badges/measure?project=codenautas_login-plus&metric=alert_status)](https://sonarcloud.io/summary/overall?id=codenautas_login-plus)
8
9
  [![qa-control](https://github.com/codenautas/login-plus/actions/workflows/qa-control.yml/badge.svg)](https://github.com/codenautas/login-plus/actions/workflows/qa-control.yml)
9
10
 
10
11
 
@@ -5,12 +5,12 @@ window.addEventListener('load',function(){
5
5
  (window.location.hash||"").split(/[#&]/g).forEach(function(pair){
6
6
  var pos=pair.indexOf('=');
7
7
  if(pos>=0){
8
- params[pair.substr(0,pos)]=pair.substr(pos+1);
8
+ params[pair.substring(0,pos)]=pair.substring(pos+1);
9
9
  }
10
10
  });
11
11
  ['username','password'].forEach(function(fieldName){
12
12
  var elem=document.getElementById(fieldName);
13
- var parameterName=fieldName.substr(0,1)
13
+ var parameterName=fieldName.substring(0,1)
14
14
  if(params[parameterName]){
15
15
  elem.value=params[parameterName];
16
16
  }
package/lib/login-plus.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  var loginPlus = {};
4
4
 
5
- var util = require('util');
6
- var crypto = require('crypto');
5
+ var util = require('node:util');
6
+ var crypto = require('node:crypto');
7
7
 
8
8
  var connectFlash = require('connect-flash');
9
9
  var MiniTools = require('mini-tools');
@@ -12,7 +12,7 @@ var session = require('express-session');
12
12
  var fs = require('fs-extra');
13
13
  var bestGlobals = require('best-globals');
14
14
  var changing = bestGlobals.changing;
15
- var Path = require('path');
15
+ var Path = require('node:path');
16
16
  var Regexplicit = require('regexplicit');
17
17
 
18
18
  loginPlus.init = function AlertDeprecated(){
@@ -43,7 +43,7 @@ function serveJade(url, opts){
43
43
  }
44
44
 
45
45
  function completeOptions(opts){
46
- if(!opts || !opts.successRedirect){
46
+ if(!opts?.successRedirect){
47
47
  console.log('login-plus lack of mandatory: opts.successRedirect');
48
48
  throw new Error('login-plus lack of mandatory: opts.successRedirect');
49
49
  }
@@ -112,7 +112,7 @@ function completeOptions(opts){
112
112
 
113
113
  function SetInitialOptions(app,opts){
114
114
  var Passport = require('passport').Passport;
115
- var passport = this.passport = new Passport();
115
+ this.passport = new Passport();
116
116
  this.LocalStrategy = require('passport-local').Strategy;
117
117
  opts = this.opts = completeOptions(opts);
118
118
  var sessionOpts=opts.session||{};
@@ -131,7 +131,7 @@ function SetInitialOptions(app,opts){
131
131
  maxAge: opts.maxAge,
132
132
  httpOnly: true,
133
133
  sameSite: 'lax',
134
- secure:(opts.allowHttpLogin?false:true)
134
+ secure:!opts.allowHttpLogin
135
135
  }
136
136
  },sessionOpts);
137
137
  }
@@ -161,7 +161,7 @@ loginPlus.Manager.prototype.phpInit = function phpInit(app,opts){
161
161
  */
162
162
  var ensureMiddlewareWihtoutPHP = this.ensureMiddleware;
163
163
  this.ensureMiddleware = function(req, res, next){
164
- if(req.$SESSION && req.$SESSION[opts.php.varLogged]){
164
+ if(req.$SESSION?.[opts.php.varLogged]){
165
165
  return next();
166
166
  }else{
167
167
  ensureMiddlewareWihtoutPHP(req, res, next);
@@ -181,7 +181,7 @@ function checkAlreadyLoggedIn(app, opts){
181
181
  }
182
182
 
183
183
  loginPlus.Manager.prototype.init = function init(app,opts){ // eslint-disable-line max-statements
184
- var thisManager = this;
184
+ var thisManager = this; // eslint-disable-line unicorn/no-this-assignment
185
185
  if(!this.passport){
186
186
  var router = '_router' in app ? app._router : app.router;
187
187
  if(router){
@@ -215,7 +215,7 @@ loginPlus.Manager.prototype.init = function init(app,opts){ // eslint-disable-li
215
215
  return fs.exists(fileNameLogin);
216
216
  }).then(function(exists){
217
217
  if(!exists){
218
- throw Error('login-plus.init fail "'+fileNameLogin+'" does not exists');
218
+ throw new Error('login-plus.init fail "'+fileNameLogin+'" does not exists');
219
219
  }
220
220
  });
221
221
  app.get(opts.baseUrl+opts.logoutUrlPath, function(req,res,next){
@@ -289,7 +289,7 @@ loginPlus.Manager.prototype.init = function init(app,opts){ // eslint-disable-li
289
289
  res.redirect(opts.redirBaseUrl+opts.loginUrlPath);
290
290
  });
291
291
  }else{
292
- if(err && opts.log.errors.getTime() > new Date().getTime()){
292
+ if(err && opts.log.errors.getTime() > Date.now()){
293
293
  console.log('chpass error',err);
294
294
  }
295
295
  req.flash('error', flashMessage || opts.messages?.internalError || 'internal error');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "login-plus",
3
3
  "description": "login service for express",
4
- "version": "1.9.2",
4
+ "version": "1.9.3",
5
5
  "author": "Codenautas <codenautas@googlegroups.com>",
6
6
  "license": "MIT",
7
7
  "repository": "codenautas/login-plus",
@@ -34,28 +34,31 @@
34
34
  "ensure-login": "^0.1.6",
35
35
  "express-session": "^1.19.0",
36
36
  "fs-extra": "^11.4.1",
37
- "mini-tools": "^1.13.12",
37
+ "mini-tools": "^1.13.14",
38
38
  "passport": "^0.7.0",
39
39
  "passport-local": "^1.0.0",
40
40
  "regexplicit": "^0.1.3",
41
41
  "session-file-store": "^1.5.0"
42
42
  },
43
43
  "devDependencies": {
44
- "ajax-best-promise": "^0.4.5",
45
- "body-parser": "^2.3.0",
44
+ "ajax-best-promise": "^0.4.7",
45
+ "body-parser": "^2.4.0",
46
46
  "concat-stream": "^2.0.0",
47
47
  "cookie-parser": "^1.4.7",
48
+ "escape-html": "^1.0.3",
49
+ "eslint-plugin-sonarjs": "^4.2.2",
50
+ "eslint-plugin-unicorn": "^79.0.0",
48
51
  "expect.js": "^0.3.1",
49
52
  "express": "^5.3.0",
50
53
  "mocha": "^12.0.3",
51
54
  "nyc": "^18.0.0",
52
- "pg-promise-strict": "^1.5.3",
55
+ "pg-promise-strict": "^1.6.0",
53
56
  "php-session": "^0.1.0",
54
57
  "pug": "^3.0.4",
55
- "qa-control": "^0.14.0",
58
+ "qa-control": "^0.14.2",
56
59
  "read-yaml-promise": "^1.0.2",
57
60
  "self-explain": "^0.11.0",
58
- "serve-content": "^1.0.8",
61
+ "serve-content": "^1.0.9",
59
62
  "sinon": "^22.1.0",
60
63
  "stylus": "^0.64.0",
61
64
  "supertest": "^7.3.1"
@@ -81,6 +84,10 @@
81
84
  "run-in": "server",
82
85
  "type": "lib",
83
86
  "coverage": 100,
84
- "gha": "all"
87
+ "gha": "all",
88
+ "silenced": [
89
+ "file_1_does_not_match_custom_2"
90
+ ],
91
+ "sonar": true
85
92
  }
86
93
  }