update
This commit is contained in:
parent
7ddd2b3e3d
commit
bc70ca4e05
1 changed files with 12 additions and 7 deletions
|
@ -5,6 +5,7 @@ import EmailService from '../EmailService'
|
|||
import fs from 'fs'
|
||||
import Mustache from 'mustache'
|
||||
import slugify from 'slugify'
|
||||
import Twig from 'twig'
|
||||
|
||||
export default class AdminOrganizationController {
|
||||
static getMany(req: express.Request, res: express.Response) {
|
||||
|
@ -23,7 +24,7 @@ export default class AdminOrganizationController {
|
|||
Organization.create({
|
||||
token: cryptoRandomString({ length: 10, type: 'distinguishable' }),
|
||||
createdAt: new Date(),
|
||||
slug: req.body.name === undefined ? undefined : slugify(req.body.name)
|
||||
slug: req.body.name === undefined ? undefined : slugify(req.body.name),
|
||||
...req.body
|
||||
}).then(data => {
|
||||
res.json({
|
||||
|
@ -76,16 +77,20 @@ export default class AdminOrganizationController {
|
|||
}
|
||||
|
||||
static sendEmailToken(req: express.Request, res: express.Response) {
|
||||
const path: string = __dirname + '/../../templates/email/token.html'
|
||||
const path: string = __dirname + '/../../views/email/token.twig'
|
||||
Organization.findById(req.params.id).then(data => {
|
||||
if (data === null) {
|
||||
return res.status(404).json({ success: false, errors: [ { code: 'not-found', message: 'Organization not found' } ] })
|
||||
}
|
||||
Twig.renderFile(path, { filename: '', settings: { foo: 'bar' } }, (err: any, html: any) => {
|
||||
console.log(html)
|
||||
console.log(err)
|
||||
EmailService.send(
|
||||
data.get('email'),
|
||||
"Votre lien secret pour modifier votre association - Forum des associations 2020",
|
||||
Mustache.render(fs.readFileSync(path).toString(), {})
|
||||
html
|
||||
)
|
||||
})
|
||||
res.json({ success: true })
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue