Build the email verification url from app context
https://github.com/strongloop/loopback/issues/408
This commit is contained in:
parent
5bb4cde593
commit
567e2530d7
|
@ -277,6 +277,7 @@ User.prototype.hasPassword = function (plain, fn) {
|
|||
|
||||
User.prototype.verify = function (options, fn) {
|
||||
var user = this;
|
||||
var userModel = this.constructor;
|
||||
assert(typeof options === 'object', 'options required when calling user.verify()');
|
||||
assert(options.type, 'You must supply a verification type (options.type)');
|
||||
assert(options.type === 'email', 'Unsupported verification type');
|
||||
|
@ -287,13 +288,20 @@ User.prototype.verify = function (options, fn) {
|
|||
options.template = path.resolve(options.template || path.join(__dirname, '..', '..', 'templates', 'verify.ejs'));
|
||||
options.user = this;
|
||||
options.protocol = options.protocol || 'http';
|
||||
options.host = options.host || 'localhost';
|
||||
|
||||
var app = this.app;
|
||||
options.host = options.host || (app && app.get('host')) || 'localhost';
|
||||
options.port = options.port || (app && app.get('port')) || 3000;
|
||||
options.restApiRoot = options.restApiRoot || (app && app.get('restApiRoot')) || '/api';
|
||||
options.verifyHref = options.verifyHref ||
|
||||
options.protocol
|
||||
+ '://'
|
||||
+ options.host
|
||||
+ User.http.path
|
||||
+ User.confirm.http.path
|
||||
+ ':'
|
||||
+ options.port
|
||||
+ options.restApiRoot
|
||||
+ userModel.http.path
|
||||
+ userModel.confirm.http.path
|
||||
+ '?uid='
|
||||
+ options.user.id
|
||||
+ '&redirect='
|
||||
|
|
|
@ -454,7 +454,9 @@ describe('User', function(){
|
|||
assert(result.email);
|
||||
assert(result.email.response);
|
||||
assert(result.token);
|
||||
assert(~result.email.response.toString('utf-8').indexOf('To: bar@bat.com'));
|
||||
var msg = result.email.response.toString('utf-8');
|
||||
assert(~msg.indexOf('/api/users/confirm'));
|
||||
assert(~msg.indexOf('To: bar@bat.com'));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue