Implement email.sendVerifyRemove
Write email.js unit tests
This commit is contained in:
@@ -98,6 +98,32 @@ class Email {
|
||||
return yield this.send(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the verification email to the user to verify key removal. Only one email
|
||||
* needs to sent to a single user id to authenticate removal of all user ids
|
||||
* that belong the a certain key id.
|
||||
* @param {Object} userId user id document
|
||||
* @param {Object} origin origin of the server
|
||||
* @yield {Object} send response from the SMTP server
|
||||
*/
|
||||
*sendVerifyRemove(options) {
|
||||
let userId = options.userId, origin = options.origin;
|
||||
let msg = {
|
||||
from: this._sender,
|
||||
to: userId,
|
||||
subject: message.verifyRemove.subject,
|
||||
text: message.verifyRemove.text,
|
||||
html: message.verifyRemove.html,
|
||||
params: {
|
||||
name: userId.name,
|
||||
baseUrl: origin.protocol + '://' + origin.host,
|
||||
keyid: encodeURIComponent(userId.keyid),
|
||||
nonce: encodeURIComponent(userId.nonce)
|
||||
}
|
||||
};
|
||||
return yield this.send(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* A generic method to send an email message via nodemailer.
|
||||
* @param {Object} from sender user id object: { name:'Jon Smith', email:'j@smith.com' }
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
{
|
||||
"verifyKey": {
|
||||
"subject": "Verify Your Key",
|
||||
"text": "Hello {{name}},\n\nplease click here to verify your key: {{baseUrl}}/api/v1/verify/?keyid={{keyid}}&nonce={{nonce}}",
|
||||
"text": "Hello {{name}},\n\nplease click here to verify your key: {{baseUrl}}/api/v1/verify?keyid={{keyid}}&nonce={{nonce}}",
|
||||
"html": ""
|
||||
},
|
||||
"verifyRemove": {
|
||||
"subject": "Verify Key Removal",
|
||||
"text": "Hello {{name}},\n\nplease click here to verify the removal of your key: {{baseUrl}}/api/v1/verifyRemove?keyid={{keyid}}&nonce={{nonce}}",
|
||||
"html": ""
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class REST {
|
||||
ctx.throw(400, 'Invalid request!');
|
||||
}
|
||||
let origin = util.getOrigin(ctx);
|
||||
yield this._publicKey({ publicKeyArmored, primaryEmail, origin });
|
||||
yield this._publicKey.put({ publicKeyArmored, primaryEmail, origin });
|
||||
ctx.status = 201;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user