Fix keyId in email links
This commit is contained in:
parent
2a42c3ee61
commit
7c294540c8
@ -55,11 +55,12 @@ class Email {
|
|||||||
* Send the verification email to the user using a template.
|
* Send the verification email to the user using a template.
|
||||||
* @param {Object} template the email template to use
|
* @param {Object} template the email template to use
|
||||||
* @param {Object} userId user id document
|
* @param {Object} userId user id document
|
||||||
|
* @param {string} keyId key id of public key
|
||||||
* @param {Object} origin origin of the server
|
* @param {Object} origin origin of the server
|
||||||
* @yield {Object} send response from the SMTP server
|
* @yield {Object} send response from the SMTP server
|
||||||
*/
|
*/
|
||||||
*send(options) {
|
*send(options) {
|
||||||
let template = options.template, userId = options.userId, origin = options.origin;
|
let template = options.template, userId = options.userId, keyId = options.keyId, origin = options.origin;
|
||||||
let message = {
|
let message = {
|
||||||
from: this._sender,
|
from: this._sender,
|
||||||
to: userId,
|
to: userId,
|
||||||
@ -69,7 +70,7 @@ class Email {
|
|||||||
params: {
|
params: {
|
||||||
name: userId.name,
|
name: userId.name,
|
||||||
baseUrl: origin.protocol + '://' + origin.host,
|
baseUrl: origin.protocol + '://' + origin.host,
|
||||||
keyid: encodeURIComponent(userId.keyid),
|
keyId: encodeURIComponent(keyId),
|
||||||
nonce: encodeURIComponent(userId.nonce)
|
nonce: encodeURIComponent(userId.nonce)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"verifyKey": {
|
"verifyKey": {
|
||||||
"subject": "Verify Your Key",
|
"subject": "Verify Your Key",
|
||||||
"text": "Hello {{name}},\n\nplease click here to verify your key:\n\n{{baseUrl}}/api/v1/verify?keyid={{keyid}}&nonce={{nonce}}",
|
"text": "Hello {{name}},\n\nplease click here to verify your key:\n\n{{baseUrl}}/api/v1/verify?id={{keyId}}&nonce={{nonce}}",
|
||||||
"html": "<p>Hello {{name}},</p><p>please <a href=\"{{baseUrl}}/api/v1/verify?keyid={{keyid}}&nonce={{nonce}}\">click here to verify</a> your key.</p>"
|
"html": "<p>Hello {{name}},</p><p>please <a href=\"{{baseUrl}}/api/v1/verify?id={{keyId}}&nonce={{nonce}}\">click here to verify</a> your key.</p>"
|
||||||
},
|
},
|
||||||
"verifyRemove": {
|
"verifyRemove": {
|
||||||
"subject": "Verify Key Removal",
|
"subject": "Verify Key Removal",
|
||||||
"text": "Hello {{name}},\n\nplease click here to verify the removal of your key:\n\n{{baseUrl}}/api/v1/verifyRemove?keyid={{keyid}}&nonce={{nonce}}",
|
"text": "Hello {{name}},\n\nplease click here to verify the removal of your key:\n\n{{baseUrl}}/api/v1/verifyRemove?id={{keyId}}&nonce={{nonce}}",
|
||||||
"html": "<p>Hello {{name}},</p><p>please <a href=\"{{baseUrl}}/api/v1/verifyRemove?keyid={{keyid}}&nonce={{nonce}}\">click here to verify</a> the removal of your key.</p>"
|
"html": "<p>Hello {{name}},</p><p>please <a href=\"{{baseUrl}}/api/v1/verifyRemove?id={{keyId}}&nonce={{nonce}}\">click here to verify</a> the removal of your key.</p>"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ const tpl = require('../../src/email/templates.json');
|
|||||||
describe('Email Integration Tests', function() {
|
describe('Email Integration Tests', function() {
|
||||||
this.timeout(20000);
|
this.timeout(20000);
|
||||||
|
|
||||||
let email, userId, origin, publicKeyArmored;
|
let email, keyId, userId, origin, publicKeyArmored;
|
||||||
|
|
||||||
const recipient = { name:'Test User', email:'safewithme.testuser@gmail.com' };
|
const recipient = { name:'Test User', email:'safewithme.testuser@gmail.com' };
|
||||||
|
|
||||||
@ -25,10 +25,10 @@ describe('Email Integration Tests', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
keyId = '0123456789ABCDF0';
|
||||||
userId = {
|
userId = {
|
||||||
name: recipient.name,
|
name: recipient.name,
|
||||||
email: recipient.email,
|
email: recipient.email,
|
||||||
keyid: '0123456789ABCDF0',
|
|
||||||
nonce: 'qwertzuioasdfghjkqwertzuio',
|
nonce: 'qwertzuioasdfghjkqwertzuio',
|
||||||
publicKeyArmored
|
publicKeyArmored
|
||||||
};
|
};
|
||||||
@ -51,22 +51,22 @@ describe('Email Integration Tests', function() {
|
|||||||
describe("send verifyKey template", () => {
|
describe("send verifyKey template", () => {
|
||||||
it('should send plaintext email', function *() {
|
it('should send plaintext email', function *() {
|
||||||
delete userId.publicKeyArmored;
|
delete userId.publicKeyArmored;
|
||||||
yield email.send({ template:tpl.verifyKey, userId, origin });
|
yield email.send({ template:tpl.verifyKey, userId, keyId, origin });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send pgp encrypted email', function *() {
|
it('should send pgp encrypted email', function *() {
|
||||||
yield email.send({ template:tpl.verifyKey, userId, origin });
|
yield email.send({ template:tpl.verifyKey, userId, keyId, origin });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("send verifyRemove template", () => {
|
describe("send verifyRemove template", () => {
|
||||||
it('should send plaintext email', function *() {
|
it('should send plaintext email', function *() {
|
||||||
delete userId.publicKeyArmored;
|
delete userId.publicKeyArmored;
|
||||||
yield email.send({ template:tpl.verifyRemove, userId, origin });
|
yield email.send({ template:tpl.verifyRemove, userId, keyId, origin });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send pgp encrypted email', function *() {
|
it('should send pgp encrypted email', function *() {
|
||||||
yield email.send({ template:tpl.verifyRemove, userId, origin });
|
yield email.send({ template:tpl.verifyRemove, userId, keyId, origin });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -24,9 +24,9 @@ describe('Email Unit Tests', () => {
|
|||||||
let userId1 = {
|
let userId1 = {
|
||||||
name: 'name1',
|
name: 'name1',
|
||||||
email: 'email1',
|
email: 'email1',
|
||||||
keyid: '0123456789ABCDF0',
|
|
||||||
nonce: 'qwertzuioasdfghjkqwertzuio'
|
nonce: 'qwertzuioasdfghjkqwertzuio'
|
||||||
};
|
};
|
||||||
|
let keyId = '0123456789ABCDF0';
|
||||||
let origin = {
|
let origin = {
|
||||||
protocol: 'http',
|
protocol: 'http',
|
||||||
host: 'localhost:8888'
|
host: 'localhost:8888'
|
||||||
@ -73,7 +73,7 @@ describe('Email Unit Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should work', function *() {
|
it('should work', function *() {
|
||||||
let info = yield email.send({ template, userId:userId1, origin});
|
let info = yield email.send({ template, userId:userId1, keyId, origin});
|
||||||
|
|
||||||
expect(info.response).to.match(/^250/);
|
expect(info.response).to.match(/^250/);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user