Implement Email DAO for sending verification mails

This commit is contained in:
Tankred Hase
2016-05-29 16:47:45 +02:00
parent c805371f0e
commit d3cce89b06
10 changed files with 235 additions and 24 deletions

View File

@@ -107,4 +107,19 @@ exports.throw = function(status, message) {
err.status = status;
err.expose = true; // display message to the client
throw err;
};
/**
* Get the server's own origin host and protocol. Required for sending
* verification links via email. If the PORT environmane variable
* is set, we assume the protocol to be 'https', since the AWS loadbalancer
* speaks 'https' externally but 'http' between the LB and the server.
* @param {Object} ctx The koa request/repsonse context
* @return {Object} The server origin
*/
exports.getOrigin = function(ctx) {
return {
protocol: process.env.PORT ? 'https' : ctx.protocol,
host: ctx.host
};
};