Merge pull request #45 from ohtuprojekti-ilmo/miscellaneous-fixes

email is now always sent, changed email content, secret acquired from…
This commit is contained in:
jexniemi
2018-11-24 15:36:59 +02:00
committed by GitHub
3 changed files with 13 additions and 19 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ topicsRouter.post('/', (req, res) => {
})
topicsRouter.put('/:id', (req, res, next) => {
//skip admin check if id is secret id
//skip admin check if id is secret_id
if (isSecretId(req.params.id)) res.locals.isSecret = true
next()
}, (req, res, next) => {
+3 -8
View File
@@ -5,9 +5,9 @@ if (process.env.NODE_ENV !== 'production') {
let port = process.env.PORT
let dbUrl = process.env.DATABASE_URI
let login = 'http://opetushallinto.cs.helsinki.fi/login'
let login = 'https://opetushallinto.cs.helsinki.fi/login'
let secret = 'secret'
let secret = process.env.SECRET
//email config
let email = {
@@ -16,16 +16,11 @@ let email = {
port: 587,
secure: false
}
let allowSendEmail = false
if (process.env.NODE_ENV === 'production') {
allowSendEmail = true
}
module.exports = {
dbUrl,
port,
login,
secret,
email,
allowSendEmail
email
}
+9 -10
View File
@@ -5,7 +5,7 @@ function sendSecretLink(secretId, address) {
const options = {
to: address,
subject: 'Link to your Software Engineering Project topic submission',
html: '<a href="http://svm-45.cs.helsinki.fi:7000/topics/' + secretId + '">Click this link to view or edit your submission</a>'
html: '<a href="http://studies.cs.helsinki.fi/projekti/topics/' + secretId + '">Click this link to view or edit your submission</a>'
}
send(options)
}
@@ -24,15 +24,14 @@ function send(options) {
text: options.text,
html: options.html
}
if (config.allowSendEmail) {
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log(error)
} else {
console.log('sent: ', info)
}
})
}
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log(error)
} else {
console.log('sent: ', info)
}
})
}
module.exports = {