Skip to content

Commit

Permalink
Revert "Merge branch 'reporting' into master"
Browse files Browse the repository at this point in the history
This reverts commit 3065777, reversing
changes made to 292fd3b.
  • Loading branch information
jortilles committed Jul 26, 2023
1 parent 3065777 commit 417aba2
Show file tree
Hide file tree
Showing 36 changed files with 104 additions and 1,231 deletions.
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

#API
eda/eda_api/config/
eda/eda_api/.vscode/
eda/eda_api/node_modules/
eda/eda_api/dist/
eda/eda_api/logs/
eda/eda_api/package-lock.json
eda/eda_api/config/custom
eda/eda_api/config/database.config.js
eda/eda_api/config/database.config-dist.js
eda/eda_api/config/oracle-config.js
eda/eda_api/config/oracle-config.docker.js
eda/eda_api/config/seed.js
Expand All @@ -15,11 +17,7 @@ eda/eda_api/config/SMPT.config.json
eda/eda_api/config/SMPT.config.json.sample
eda/eda_api/lib/module/uploads/users
eda/eda_api/chromium_dependencies.txt
eda/eda_api/config/database.config.js
eda/sda_api/dist
eda/sda_api/src/config/seed.js
eda/sda_api/src/views/postform.html
eda/sda_api/package-lock.json


#APP

Expand All @@ -30,4 +28,10 @@ eda/eda_app/dist
eda/eda_app/AddEdaCharInstructions.txt
eda/eda_app/package-lock.json
eda/eda_app/src/app/config/
eda/eda_api/config/database.config.js
eda/sda_api/dist
eda/sda_api/src/config/seed.js
eda/sda_api/src/views/postform.html
eda/sda_api/package-lock.json

eda/eda_api/config/SCRM
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,3 @@ We just created documentation site http://edadoc.jortilles.com/en/index.html#/





39 changes: 0 additions & 39 deletions eda/eda_api/config/base_datamodel.json

This file was deleted.

3 changes: 3 additions & 0 deletions eda/eda_api/config/database.config.js.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
url: "mongodb://localhost:27017/EDA"
};
14 changes: 0 additions & 14 deletions eda/eda_api/config/sinergiacrm.config.js

This file was deleted.

27 changes: 0 additions & 27 deletions eda/eda_api/lib/guards/updateModel-guard.ts

This file was deleted.

2 changes: 0 additions & 2 deletions eda/eda_api/lib/module/admin/users/model/user.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export interface IUser extends mongoose.Document {
password: String;
img: String;
role: any;
active: Boolean;
}


Expand All @@ -24,7 +23,6 @@ const UserSchema = new mongoose.Schema({
password: { type: String, required: [true, 'La contraseña es necesaria'] },
img: { type: String, required: false },
role: [{ type: mongoose.Types.ObjectId, ref: 'Group' }],
active: { type:String, required:false}
}, { collection: 'users', strict: false });

UserSchema.plugin(uniqueValidator, { message: 'Ya existe un usuario con este {PATH}' });
Expand Down
20 changes: 3 additions & 17 deletions eda/eda_api/lib/module/admin/users/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,10 @@ export class UserController {
const userEda = await UserController.getUserInfoByEmail(body.email, false);

if (! await bcrypt.compareSync(body.password, userEda.password)) {
// Introduit arrel de SinergiaCRM
// Comprobem també MD5 i GlassFis
// Busca artxiu de configuracio de Sinergia
const scrm = path.resolve(__dirname, `../../../../config/sinergiacrm.config.js`);
if (fs.existsSync(scrm)) {
const hash = crypto.createHash('md5').update(body.password).digest("hex");
if(hash.toString() !== userEda.password.toString()){
//Si no es un md5 directe
const hash2 = userEda.password.toString().replace(/^\$2y(.+)$/i, '$2a$1');
await bcrypt.compare( hash , hash2).then(function(res){
if( res == false){
return next(new HttpException(400, 'Incorrect credentials - password'));
}
});
}
}else{


return next(new HttpException(400, 'Incorrect credentials - password'));
}



}
Expand Down
27 changes: 3 additions & 24 deletions eda/eda_api/lib/module/dashboard/dashboard.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,12 @@ export class DashboardController {

// Filtre de seguretat per les taules. Si no es te permis sobre una taula es posa com a oculta.
// Per si de cas es fa servir a una relació.
let uniquesForbiddenTables = DashboardController.getForbiddenTables(
const uniquesForbiddenTables = DashboardController.getForbiddenTables(
toJson,
userGroups,
req.user._id
)

// Esto se hace para hacer un bypass de la seguridad en caso de que el usuario sea anonimo y por lo tanto
// un informe público
if(req.user._id == '135792467811111111111112'){
console.log('ANONYMOUS USER QUERY....NO PERMISSIONS APPLY HERE.....');
uniquesForbiddenTables = [];
}


try {
// Poso taules prohivides a false
if (uniquesForbiddenTables.length > 0) {
Expand Down Expand Up @@ -638,19 +630,11 @@ export class DashboardController {
}
const dataModelObject = JSON.parse(JSON.stringify(dataModel))
/** Forbidden tables */
let uniquesForbiddenTables = DashboardController.getForbiddenTables(
const uniquesForbiddenTables = DashboardController.getForbiddenTables(
dataModelObject,
req['user'].role,
req.user._id
);

if( req.user._id == '135792467811111111111112'){
console.log('ANONYMOUS USER QUERY....NO PERMISSIONS APPLY HERE.....');
uniquesForbiddenTables = [];

}


)
let mylabels = []
let myQuery: any
if (uniquesForbiddenTables.length > 0) {
Expand Down Expand Up @@ -1022,11 +1006,6 @@ static isNotNumeric(val){

/**Check if an user can or not see a data model. */
static securityCheck (dataModel: any, user: any) {

if(user._id== '135792467811111111111112'){
console.log('Anonymous access');
return true;
}
if (dataModel.ds.metadata.model_granted_roles.length > 0) {
const users = []
const roles = []
Expand Down
55 changes: 26 additions & 29 deletions eda/eda_api/lib/module/datasource/datasource.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import ConnectionModel from './model/connection.model';
import { EnCrypterService } from '../../services/encrypter/encrypter.service';
import BigQueryConfig from './model/BigQueryConfig.model';
import CachedQuery, { ICachedQuery } from '../../services/cache-service/cached-query.model';
import { Mongoose, QueryOptions } from 'mongoose';
import { QueryOptions } from 'mongoose';
import { upperCase } from 'lodash';
import Group from '../../module/admin/groups/model/group.model';
import { json } from 'body-parser';
const cache_config = require('../../../config/cache.config');

export class DataSourceController {
Expand Down Expand Up @@ -42,6 +41,7 @@ export class DataSourceController {
if (err) {
return next(new HttpException(404, 'Datasouce not found'));
}

// ocultem el password
dataSource.ds.connection.password = EnCrypterService.decode(dataSource.ds.connection.password);
dataSource.ds.connection.password = '__-(··)-__';
Expand All @@ -54,7 +54,7 @@ export class DataSourceController {
}
}

/** aQUSTA FUNCIÓ RETORNA TOTS ELS DATASOURCES */
/** AQUSTA FUNCIÓ RETORNA TOTS ELS DATASOURCES */
static async GetDataSourcesNames(req: Request, res: Response, next: NextFunction) {
let options:QueryOptions = {};
DataSource.find({}, '_id ds.metadata.model_name ds.security', options, (err, ds) => {
Expand Down Expand Up @@ -155,9 +155,7 @@ export class DataSourceController {
const names = JSON.parse(JSON.stringify(ds));
for (let i = 0, n = names.length; i < n; i += 1) {
const e = names[i];
if (e._id != "111111111111111111111111") {
output.push({ _id: e._id, model_name: e.ds.metadata.model_name });
}
}
output.sort((a,b) => (upperCase(a.model_name) > upperCase(b.model_name)) ? 1 :
((upperCase(b.model_name) > upperCase(a.model_name)) ? -1 : 0));
Expand All @@ -171,21 +169,18 @@ export class DataSourceController {
return next(new HttpException(500, 'Error loading DataSources'));
}
const names = JSON.parse(JSON.stringify(ds));

for (let i = 0, n = names.length; i < n; i += 1) {
const e = names[i];
// Si tenim propietari....
if (e.ds.metadata.model_owner) {
// Si el model es meu....
if ( (req.user._id == e.ds.metadata.model_owner)) {
// Si no es diu el _id no es el de SinergiaDA...
if (e._id != "111111111111111111111111") {
if (req.user._id == e.ds.metadata.model_owner) {
output.push({ _id: e._id, model_name: e.ds.metadata.model_name });
}
}

}
}
}
output.sort((a,b) => (upperCase(a.model_name) > upperCase(b.model_name)) ? 1 : ((upperCase(b.model_name) > upperCase(a.model_name)) ? -1 : 0));
return res.status(200).json({ ok: true, ds: output });
});
Expand Down Expand Up @@ -324,10 +319,10 @@ export class DataSourceController {
} else {

try {
const cn = req.qs.type !== 'bigquery' ? new ConnectionModel(req.qs.user, req.qs.host, req.qs.database,
req.qs.password, req.qs.port, req.qs.type,
req.body.poolLimit, req.qs.schema, req.qs.sid, req.qs.warehouse)
: new BigQueryConfig(req.qs.type, req.qs.database, req.qs.project_id);
const cn = req.qs.type !== 'bigquery' ?
new ConnectionModel(req.qs.user, req.qs.host, req.qs.database, req.qs.password, req.qs.port,
req.qs.type, req.qs.schema, req.body.poolLimit, req.qs.sid, req.qs.warehouse
) : new BigQueryConfig(req.qs.type, req.qs.database, req.qs.project_id);

const manager = await ManagerConnectionService.testConnection(cn);
await manager.tryConnection();
Expand All @@ -348,8 +343,10 @@ export class DataSourceController {
const actualDS = await DataSourceController.getMongoDataSource(req.params.id);
const passwd = req.qs.password === '__-(··)-__' ? EnCrypterService.decode(actualDS.ds.connection.password) : req.qs.password;

const cn = new ConnectionModel(req.qs.user, req.qs.host, req.qs.database, passwd,
req.qs.port, req.qs.type, req.qs.schema, req.body.poolLimit, req.qs.sidm, req.qs.warehouse);
const cn = new ConnectionModel(
req.qs.user, req.qs.host, req.qs.database, passwd, req.qs.port,
req.qs.type, req.qs.schema, req.body.poolLimit, req.qs.sidm, req.qs.warehouse
);
const manager = await ManagerConnectionService.testConnection(cn);
await manager.tryConnection();
return res.status(200).json({ ok: true });
Expand Down Expand Up @@ -425,13 +422,15 @@ export class DataSourceController {

static async GenerateDataModelSql(req: Request, res: Response, next: NextFunction) {
try {
const cn = new ConnectionModel(req.body.user, req.body.host, req.body.database,
req.body.password, req.body.port, req.body.type, req.body.schema, req.body.poolLimit, req.body.sid, req.qs.warehouse);
const cn = new ConnectionModel(
req.body.user, req.body.host, req.body.database, req.body.password, req.body.port,
req.body.type, req.body.schema, req.body.poolLimit, req.body.sid, req.qs.warehouse
);
const manager = await ManagerConnectionService.testConnection(cn);
const tables = await manager.generateDataModel(req.body.optimize, req.body.filter, req.body.name);
const CC = req.body.allowCache === 1 ? cache_config.DEFAULT_CACHE_CONFIG : cache_config.DEFAULT_NO_CACHE_CONFIG;


const datasource: IDataSource = new DataSource({
ds: {
connection: {
Expand All @@ -443,6 +442,7 @@ export class DataSourceController {
searchPath: req.body.schema || manager.GetDefaultSchema(),
user: req.body.user,
password: EnCrypterService.encrypt(req.body.password || 'no'),
poolLimit: req.body.poolLimit,
sid: req.body.sid,
warehouse: req.body.warehouse
},
Expand All @@ -459,23 +459,18 @@ export class DataSourceController {
tables: tables
}
}
});

});

datasource.save((err, data_source) => {

if (err) {


console.log(err);
return next(new HttpException(500, `Error saving the datasource`));
}

return res.status(201).json({ ok: true, data_source_id: data_source._id });
});
});

} catch (err) {

next(err);
}
}
Expand All @@ -501,8 +496,10 @@ export class DataSourceController {
const actualDS = await DataSourceController.getMongoDataSource(req.params.id);
const passwd = req.body.password === '__-(··)-__' ? EnCrypterService.decode(actualDS.ds.connection.password) : req.body.password

const cn = new ConnectionModel(req.body.user, req.body.host, req.body.database, passwd,
req.body.port, req.body.type, req.body.schema, req.body.poolLimit, req.body.sid, req.qs.warehouse);
const cn = new ConnectionModel(
req.body.user, req.body.host, req.body.database, passwd, req.body.port,
req.body.type, req.body.schema, req.body.poolLimit, req.body.sid, req.qs.warehouse
);
const manager = await ManagerConnectionService.testConnection(cn);
const storedDataModel = JSON.parse(JSON.stringify(actualDS));
let tables = [];
Expand Down
Loading

0 comments on commit 417aba2

Please sign in to comment.