.
This commit is contained in:
parent
b943d74ea3
commit
1406bdcbb4
@ -73,10 +73,9 @@ const generateControllers = (service, extraControllers = {}, options = {}) => {
|
||||
},
|
||||
|
||||
create: (config) => {
|
||||
console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
|
||||
return async (req, res, next) => {
|
||||
try {
|
||||
console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2');
|
||||
console.log('SERVICE CREATE ->', req.body);
|
||||
const result = await service.create(req.body, buildContext(req, config));
|
||||
return handleResultResponse(result, null, null, res, httpStatus.CREATED)
|
||||
} catch (error) {
|
||||
@ -89,8 +88,7 @@ const generateControllers = (service, extraControllers = {}, options = {}) => {
|
||||
return async (req, res, next) => {
|
||||
try {
|
||||
const params = extractParamsFromRequest(req, res, _options.params.update);
|
||||
console.log('paraaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaams');
|
||||
console.log(req.body);
|
||||
console.log('SERVICE UPDATE ->', params, req.body);
|
||||
|
||||
const response = await service.update(params, req.body, buildContext(req, config));
|
||||
// https://sequelize.org/master/class/lib/model.js~Model.html#static-method-update
|
||||
@ -118,6 +116,7 @@ console.log('paraaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaams');
|
||||
return async (req, res, next) => {
|
||||
try {
|
||||
const params = extractParamsFromRequest(req, res, _options.params.delete);
|
||||
console.log('SERVICE DELETE ->', params);
|
||||
const result = await service.delete(params, buildContext(req, config));
|
||||
return handleResultResponse(result, null, req.params, res, httpStatus.NO_CONTENT);
|
||||
} catch (error) {
|
||||
|
||||
@ -43,7 +43,27 @@ app.use(methodOverride());
|
||||
app.use(helmet());
|
||||
|
||||
// enable CORS - Cross Origin Resource Sharing
|
||||
var allowedOrigins = ['http://localhost:8080', 'http://127.0.0.1:8080'];
|
||||
|
||||
app.use(cors({
|
||||
origin: function (origin, callback) { // allow requests with no origin
|
||||
// (like mobile apps or curl requests)
|
||||
if (!origin) {
|
||||
return callback(null, true);
|
||||
}
|
||||
|
||||
if (allowedOrigins.indexOf(origin) === -1) {
|
||||
var msg = 'The CORS policy for this site does not ' +
|
||||
'allow access from the specified Origin.';
|
||||
return callback(new Error(msg), false);
|
||||
}
|
||||
|
||||
return callback(null, true);
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
/*app.use(cors({
|
||||
origin: '*',
|
||||
exposeHeaders: [
|
||||
"WWW-Authenticate",
|
||||
@ -64,6 +84,7 @@ app.use(cors({
|
||||
"HEAD"
|
||||
],
|
||||
allowHeaders: [
|
||||
"Access-Control-Allow-Origin",
|
||||
"Content-Type",
|
||||
"X-CSRF-Token",
|
||||
"X-Requested-With",
|
||||
@ -78,7 +99,7 @@ app.use(cors({
|
||||
"X-Frame-Options",
|
||||
"Origin",
|
||||
],
|
||||
}));
|
||||
}));*/
|
||||
|
||||
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ passport.use('jwt', new CustomStrategy(async (req, done) => {
|
||||
}
|
||||
|
||||
const result = securityHelper.verify(token);
|
||||
console.log('token result => ', result);
|
||||
//console.log('token result => ', result);
|
||||
|
||||
if (result && result.id) {
|
||||
//recuperamos el usuario de la petición
|
||||
@ -114,16 +114,16 @@ passport.use('jwt', new CustomStrategy(async (req, done) => {
|
||||
if (user) {
|
||||
user = user.toJSON();
|
||||
delete user.password;
|
||||
console.log('Usuario encontrado', user);
|
||||
//console.log('Usuario encontrado', user);
|
||||
return done(null, user, { message: 'Logged in Successfully' });
|
||||
}
|
||||
else {
|
||||
console.log('Usuario no encontrado');
|
||||
//console.log('Usuario no encontrado');
|
||||
return done(null, false, { message: 'Unauthorized. User not found.' });
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log('Token no válido');
|
||||
//console.log('Token no válido');
|
||||
return done(null, false, { message: 'Unauthorized. Invalid token.' });
|
||||
}
|
||||
|
||||
|
||||
@ -72,6 +72,14 @@ function extractProviderInfo(videoId) {
|
||||
}
|
||||
|
||||
function determineProviderInfo(url) {
|
||||
console.log(url);
|
||||
|
||||
if (!url) return {
|
||||
provider: undefined,
|
||||
code: undefined,
|
||||
class: undefined,
|
||||
};
|
||||
|
||||
var info = parseVideo(url);
|
||||
return {
|
||||
provider: info.type,
|
||||
|
||||
@ -107,16 +107,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
isValidPassword: async (password, candidate) => {
|
||||
console.log('aaaaaaaaaaaaaaaaaaa3');
|
||||
console.log(password);
|
||||
console.log(candidate);
|
||||
|
||||
|
||||
result = await bCrypt.compareSync(candidate, password);
|
||||
|
||||
console.log('resultado');
|
||||
console.log(result);
|
||||
result = true;
|
||||
result = await bCrypt.compareSync(candidate, password);
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
@ -214,6 +214,7 @@ const generateService = (model, extraMethods = {}, options = defaultOptions) =>
|
||||
if (extraMethods.beforeUpdate) {
|
||||
values = extraMethods.beforeUpdate(values, findOptions, context);
|
||||
}
|
||||
console.log(values, findOptions);
|
||||
return await model.scope(context.scopes).update(values, findOptions)
|
||||
},
|
||||
|
||||
|
||||
@ -53,10 +53,7 @@ routes.get('/multimedias/:id', //cacheSuccesses('24 hours'),
|
||||
const multimediasInputType = Joi.object().keys({
|
||||
entityId: Joi.string().required(),
|
||||
entityName: Joi.string().required(),
|
||||
name: Joi.string().optional(),
|
||||
description: Joi.string().optional(),
|
||||
type: Joi.string().required(),
|
||||
class: Joi.string().required(),
|
||||
multimediafileId: Joi.string().required()
|
||||
});
|
||||
|
||||
@ -64,7 +61,6 @@ const multimediasInputType = Joi.object().keys({
|
||||
routes.post('/admin/multimedias/',
|
||||
isAdministratorUser,
|
||||
SchemaValidator(multimediasInputType, true),
|
||||
//uploader.single('file'),
|
||||
multimediaController.create()
|
||||
);
|
||||
|
||||
|
||||
@ -49,6 +49,8 @@ routes.post('/admin/multimediafiles/',
|
||||
SchemaValidator(multimediaFilesInputType, true),
|
||||
cdnUpload().single('file'),
|
||||
(req, res, next) => {
|
||||
console.log('POST ****************************');
|
||||
console.log(req.file, req.data);
|
||||
if (req.file) {
|
||||
req.body.url = req.file.path.replace(config.uploads.path, '');
|
||||
req.body.provider = 'cdn';
|
||||
@ -62,9 +64,11 @@ routes.post('/admin/multimediafiles/',
|
||||
// Modificación
|
||||
routes.put('/admin/multimediafiles/:id',
|
||||
isAdministratorUser,
|
||||
//SchemaValidator(multimediaFilesInputType, true),
|
||||
SchemaValidator(multimediaFilesInputType, true),
|
||||
cdnUpload().single('file'),
|
||||
(req, res, next) => {
|
||||
console.log('PUT ****************************');
|
||||
console.log(req.file, req.data, req.body);
|
||||
if (req.file) {
|
||||
req.body.url = req.file.path.replace(config.uploads.path, '');
|
||||
req.body.provider = 'cdn';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user