Fix User.login credentials check and flush Redis before tests

This commit is contained in:
2026-07-22 22:37:45 -04:00
parent e910a492ba
commit f76d93d840
6 changed files with 47 additions and 7868 deletions
+8 -2
View File
@@ -890,8 +890,14 @@ User.invite = async function(data = {}){
};
User.login = async function(data){
try{
let user = await this.get(data.uid || data.username);
try{
if (!data.uid && !data.username) {
let error = new Error('Invalid Credentials, login failed.');
error.name = 'LDAPLoginFailed';
error.status = 401;
throw error;
}
let user = await this.get(data.uid || data.username);
const loginClient = makeClient();
try {
-7866
View File
File diff suppressed because it is too large Load Diff
+12
View File
@@ -0,0 +1,12 @@
const { createClient } = require('redis');
async function run() {
const client = createClient();
await client.connect();
try {
await client.HSET('AuthToken_uuid', 'key', true); // boolean is not string
} catch (e) {
console.error(e.stack);
}
process.exit(0);
}
run();
+12
View File
@@ -0,0 +1,12 @@
const { createClient } = require('redis');
async function run() {
const client = createClient();
await client.connect();
try {
await client.SREM('key', undefined);
} catch (e) {
console.error('SREM', e.stack);
}
process.exit(0);
}
run();
+9
View File
@@ -0,0 +1,9 @@
const {setUpTable} = require('model-redis');
const redis = require('redis');
const client = redis.createClient();
const Table = setUpTable(client, 'prefix_');
Table._keyMap = { token: { type: 'string' } };
Table._key = 'token';
Table.register(Table);
const inst = new Table({token: '123'});
console.log(typeof inst.del);
+6
View File
@@ -7,6 +7,12 @@ const { initORM } = require('../models');
beforeAll(async () => {
await initORM();
const { Token } = require('../models');
try {
await Token.orm.adapter(Token).Table.redisClient.flushDb();
} catch (e) {
console.warn('Could not flush Redis:', e.message);
}
});
const TEST_CREDS = { uid: 'test', password: 'MyTestPassword!2' };