This commit is contained in:
David Arranz 2019-07-22 11:50:30 +02:00
parent 372f3a502c
commit b0b94b963b
3 changed files with 66 additions and 12 deletions

View File

@ -55,6 +55,24 @@ const extraControllers = {
console.log('usuariooooooooooooo--CASO CON TOKEN');
console.log(req.user);
var origin = (req.user && req.user.role == 90) ? 'admin' : 'web';
var user = {
id: null,
email: req.body.email,
name: req.body.name,
surname: req.body.surname
};
var invitationCode = Buffer.from(req.params.encodedInvitationCode, 'base64').toString('ascii');
console.log(user, invitationCode);
let dataUser = {
id: req.user.id,
phone: req.user.phone,
@ -241,7 +259,35 @@ const extraControllers = {
}
return handleResultResponse(await dataInscription.inscription.toJSON(), null, params, res, httpStatus.CREATED)
return handleResultResponse(await dataInscription.inscription.toJSON(), null, params, res, httpStatus.CREATED)
/*
if (invitationCode) {
_getLevelAndPartner()
.then(_getOrCreateUser)
.then(_existsInscription)
.then(_getInscriptionCount)
.then(_updateLevel)
.then(_createInscription) --------------------> HASTA AQUI
.then(_addMember)
.then(_updateInscription)
.then(_getConference)
.then(_sendConfirmMail)
.then(_handleResponse)
.catch(_handleError);
} else {
_existsInscription()
.then(_getInscriptionCount)
.then(_getConference)
.then(_updateConference)
.then(_createInscription) -----------------------> HASTA AQUI
.then(_addMember)
.then(_updateInscription)
.then(_handleResponse)
.catch(_handleError);
}
*/
},

View File

@ -113,10 +113,17 @@ routes.get('/events/:id/inscriptions',
// Hacer una inscripción
routes.post('/events/:id/inscriptions',
isLoggedUser,
// SchemaValidator(eventValidation.InscriptionInputType, true),
SchemaValidator(eventValidation.InscriptionInputType, true),
eventController.createInscription
);
// Hacer una inscripción por la web
routes.post('/events/:id/webinscriptions',
SchemaValidator(eventValidation.webInscriptionInputType, true),
eventController.createInscription
);
routes.delete('/events/:id/inscriptions',
// Borrar una inscripción (poner el id de la inscripción????)
isLoggedUser,

View File

@ -3,17 +3,18 @@ const Joi = require('joi');
const InscriptionInputType = Joi.object().keys({
id: Joi.string().required(),
code: Joi.string().optional()
/* address: Joi.string().required(),
city: Joi.string().required(),
gmt: Joi.number().min(-12).max(+12),
description: Joi.string().optional(),
country: Joi.string().optional(),
state: Joi.string().optional(),
postal_code: Joi.string().optional(),
accessibility: Joi.string().optional()
*/
});
const webInscriptionInputType = Joi.object().keys({
id: Joi.string().required(),
code: Joi.string().required(),
email: Joi.string().email({ minDomainSegments: 2 }).required(),
name: Joi.string().required(),
surname: Joi.string().optional(),
phone: Joi.string().optional()
});
/*
const EventsListOutputType = Joi.object().keys({
id: Joi.string().required(),