larvituser 0.19.0 → 0.19.1
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/index.js +3 -0
- package/package.json +2 -2
- package/test/00test.js +22 -0
package/index.js
CHANGED
|
@@ -344,6 +344,9 @@ User.prototype.fromUserAndPass = function fromUserAndPass(username, password, cb
|
|
|
344
344
|
userUuid,
|
|
345
345
|
userObj;
|
|
346
346
|
|
|
347
|
+
if (typeof username !== 'string') return cb(new Error('Username must be a string'), false);
|
|
348
|
+
if (typeof password !== 'string') return cb(new Error('Password must be a string'), false);
|
|
349
|
+
|
|
347
350
|
username = username.trim();
|
|
348
351
|
password = password.trim();
|
|
349
352
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "larvituser",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.1",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Mikael 'Lilleman' Göransson",
|
|
6
6
|
"email": "lilleman@larvit.se",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"description": "User module for node.js",
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"freeport": "1.0.5",
|
|
22
|
-
"mocha": "6.
|
|
22
|
+
"mocha": "6.2.2",
|
|
23
23
|
"mocha-eslint": "5.0.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
package/test/00test.js
CHANGED
|
@@ -53,6 +53,11 @@ before(function (done) {
|
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
+
// Clear DB
|
|
57
|
+
tasks.push(function (cb) {
|
|
58
|
+
db.removeAllTables(cb);
|
|
59
|
+
});
|
|
60
|
+
|
|
56
61
|
// Check for empty db
|
|
57
62
|
tasks.push(function (cb) {
|
|
58
63
|
db.query('SHOW TABLES', function (err, rows) {
|
|
@@ -202,6 +207,23 @@ describe('User', function () {
|
|
|
202
207
|
});
|
|
203
208
|
});
|
|
204
209
|
|
|
210
|
+
it('should fail to log in user if username is an array', function (done) {
|
|
211
|
+
userLib.fromUserAndPass(['lill', 'eman'], 'foobar', function (err, user) {
|
|
212
|
+
assert(err.message === 'Username must be a string', 'Error should be "Username must be a string"');
|
|
213
|
+
assert(user === false, 'user should be false');
|
|
214
|
+
done();
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
it('should fail to log in user if password is an array', function (done) {
|
|
220
|
+
userLib.fromUserAndPass('lilleman', ['foo', 'bar'], function (err, user) {
|
|
221
|
+
assert(err.message === 'Password must be a string', 'Error should be "Password must be a string"');
|
|
222
|
+
assert(user === false, 'user should be false');
|
|
223
|
+
done();
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
205
227
|
it('should log in user by field', function (done) {
|
|
206
228
|
userLib.fromField('firstname', 'migal', function (err, user) {
|
|
207
229
|
if (err) throw err;
|