Fix User.login credentials check and flush Redis before tests
This commit is contained in:
@@ -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 {
|
||||
|
||||
Generated
-7866
File diff suppressed because it is too large
Load Diff
@@ -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();
|
||||
@@ -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();
|
||||
@@ -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);
|
||||
@@ -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' };
|
||||
|
||||
Reference in New Issue
Block a user