This commit is contained in:
lesion
2019-06-08 13:18:47 +02:00
parent c408c44676
commit d6501b1a5b
17 changed files with 63 additions and 34 deletions

View File

@@ -8,6 +8,7 @@ const mail = {
send(addresses, template, locals) {
const email = new Email({
views: { root: path.join(__dirname, '..', 'emails') },
htmlToText: false,
juice: true,
juiceResources: {
preserveImportant: true,
@@ -25,7 +26,7 @@ const mail = {
},
transport: config.SECRET_CONF.smtp
})
return email.send({
const msg = {
template,
message: {
to: addresses,
@@ -37,7 +38,11 @@ const mail = {
config: config.SHARED_CONF,
datetime: datetime => moment(datetime).format('ddd, D MMMM HH:mm')
}
})
}
return email.send(msg)
.catch(e => {
console.error(e)
})
}
}

View File

@@ -5,7 +5,7 @@ module.exports = (sequelize, DataTypes) => {
const user = sequelize.define('user', {
email: {
type: DataTypes.STRING,
unique: { msg: 'err.register_error' },
unique: true,
index: true,
allowNull: false
},
@@ -16,7 +16,7 @@ module.exports = (sequelize, DataTypes) => {
is_active: DataTypes.BOOLEAN
}, {
defaultScope: {
exclude: ['password', 'recover_code']
attributes: { exclude: ['password', 'recover_code'] }
}
})

View File

@@ -1,59 +0,0 @@
/**
* GANCIO CONFIGURATION
*/
const env = process.env.NODE_ENV || 'development'
/**
* Database configuration
* `development` configuration is enabled running `yarn dev`
* while `production` with `yarn start`
* ref: http://docs.sequelizejs.com/class/lib/sequelize.js~Sequelize.html#instance-constructor-constructor
*/
const DB_CONF = {
development: {
storage: __dirname + '/db.sqlite',
dialect: 'sqlite',
},
production: {
username: '',
password: '',
database: 'gancio',
host: 'localhost',
dialect: 'postgres',
logging: false
},
}
const SECRET_CONF = {
// where events/users confirmation email are sent
admin: 'gancio@example.com',
db: DB_CONF[env],
// jwt salt secret (generate it randomly)
secret: '',
// smtp account to send email
smtp: {
host: process.env.SMTP_HOST || 'mail.example.com',
secure: true,
auth: {
user: process.env.SMTP_USER || 'gancio@example.com',
pass: process.env.SMTP_PASS || ''
}
},
}
/**
* Main Gancio configuration
*/
const SHARED_CONF = {
locale: 'it',
title: 'GANCIO',
description: 'A calendar for radical communities',
baseurl: env === 'development' ? 'http://localhost:3000': 'https://gancio.example.com',
env
}
module.exports = { SHARED_CONF, SECRET_CONF }

View File

@@ -1,3 +1,3 @@
p= t('recover_email')
p= t('mail.recover')
<a href="#{config.baseurl}/recover/#{user.recover_code}">#{t('press here')}</a>

View File

@@ -1 +1 @@
= `[Gancio] Richiesta registrazione`
| [Gancio] #{t('register.request')}

View File

@@ -0,0 +1 @@
| dioicane ciao

View File

@@ -10,7 +10,7 @@ module.exports = {
},
email: {
type: Sequelize.STRING,
unique: { msg: 'err.register_error' },
unique: true,
index: true,
allowNull: false
},