mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Re-rename 'confirm' to 'verify'.
This commit is contained in:
@@ -6,13 +6,13 @@ if (!Accounts._options) {
|
||||
}
|
||||
|
||||
// @param options {Object} an object with fields:
|
||||
// - sendConfirmationEmail {Boolean}
|
||||
// Send email address confirmation emails to new users created from
|
||||
// - sendVerificationEmail {Boolean}
|
||||
// Send email address verification emails to new users created from
|
||||
// client signups.
|
||||
// - forbidClientAccountCreation {Boolean}
|
||||
// Do not allow clients to create accounts directly.
|
||||
Accounts.config = function(options) {
|
||||
_.each(["sendConfirmationEmail", "forbidClientAccountCreation"], function(key) {
|
||||
_.each(["sendVerificationEmail", "forbidClientAccountCreation"], function(key) {
|
||||
if (key in options) {
|
||||
if (key in Accounts._options)
|
||||
throw new Error("Can't set `" + key + "` more than once");
|
||||
|
||||
@@ -260,9 +260,9 @@
|
||||
return Meteor.users.find(
|
||||
{_id: this.userId},
|
||||
{fields: {profile: 1, username: 1,
|
||||
// We do let the UI know if emails are confirmed but we don't
|
||||
// want to publish the confirmationTokens field!
|
||||
'emails.address': 1, 'emails.confirmed': 1}});
|
||||
// We do let the UI know if emails are verified but we don't
|
||||
// want to publish the verificationTokens field!
|
||||
'emails.address': 1, 'emails.verified': 1}});
|
||||
else {
|
||||
this.complete();
|
||||
return null;
|
||||
|
||||
@@ -18,16 +18,16 @@ Accounts.emailTemplates = {
|
||||
+ "Thanks.\n";
|
||||
}
|
||||
},
|
||||
confirmEmail: {
|
||||
verifyEmail: {
|
||||
subject: function(user) {
|
||||
return "How to confirm your account email on " + Accounts.emailTemplates.siteName;
|
||||
return "How to verify email address on " + Accounts.emailTemplates.siteName;
|
||||
},
|
||||
text: function(user, url) {
|
||||
var greeting = (user.profile && user.profile.name) ?
|
||||
("Hello " + user.profile.name + ",") : "Hello,";
|
||||
return greeting + "\n"
|
||||
+ "\n"
|
||||
+ "To confirm your account email, simply click the link below.\n"
|
||||
+ "To verify your account email, simply click the link below.\n"
|
||||
+ "\n"
|
||||
+ url + "\n"
|
||||
+ "\n"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
var email4;
|
||||
|
||||
var resetPasswordToken;
|
||||
var confirmEmailToken;
|
||||
var verifyEmailToken;
|
||||
var enrollAccountToken;
|
||||
|
||||
Accounts._isolateLoginTokenForTest();
|
||||
@@ -29,7 +29,7 @@
|
||||
function (test, expect) {
|
||||
Meteor.call("getInterceptedEmails", email1, expect(function (error, result) {
|
||||
test.notEqual(result, undefined);
|
||||
test.equal(result.length, 2); // the first is the email confirmation
|
||||
test.equal(result.length, 2); // the first is the email verification
|
||||
var content = result[1];
|
||||
|
||||
var match = content.match(
|
||||
@@ -65,7 +65,7 @@
|
||||
}
|
||||
]);
|
||||
|
||||
var getConfirmEmailToken = function (email, test, expect) {
|
||||
var getVerifyEmailToken = function (email, test, expect) {
|
||||
Meteor.call("getInterceptedEmails", email, expect(function (error, result) {
|
||||
test.isFalse(error);
|
||||
test.notEqual(result, undefined);
|
||||
@@ -74,9 +74,9 @@
|
||||
|
||||
var match = content.match(
|
||||
new RegExp(window.location.protocol + "//" +
|
||||
window.location.host + "/#\\/confirm-email/(\\S*)"));
|
||||
window.location.host + "/#\\/verify-email/(\\S*)"));
|
||||
test.isTrue(match);
|
||||
confirmEmailToken = match[1];
|
||||
verifyEmailToken = match[1];
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
});
|
||||
};
|
||||
|
||||
testAsyncMulti("accounts emails - confirm email flow", [
|
||||
testAsyncMulti("accounts emails - verify email flow", [
|
||||
function (test, expect) {
|
||||
email2 = Meteor.uuid() + "-intercept@example.com";
|
||||
email3 = Meteor.uuid() + "-intercept@example.com";
|
||||
@@ -106,15 +106,15 @@
|
||||
function (test, expect) {
|
||||
test.equal(Meteor.user().emails.length, 1);
|
||||
test.equal(Meteor.user().emails[0].address, email2);
|
||||
test.isFalse(Meteor.user().emails[0].confirmed);
|
||||
// We should NOT be publishing confirmation tokens!
|
||||
test.isFalse(_.has(Meteor.user().emails[0], 'confirmationTokens'));
|
||||
test.isFalse(Meteor.user().emails[0].verified);
|
||||
// We should NOT be publishing verification tokens!
|
||||
test.isFalse(_.has(Meteor.user().emails[0], 'verificationTokens'));
|
||||
},
|
||||
function (test, expect) {
|
||||
getConfirmEmailToken(email2, test, expect);
|
||||
getVerifyEmailToken(email2, test, expect);
|
||||
},
|
||||
function (test, expect) {
|
||||
// Log out, to test that confirmEmail logs us back in. (And if we don't
|
||||
// Log out, to test that verifyEmail logs us back in. (And if we don't
|
||||
// do that, waitUntilLoggedIn won't be able to prevent race conditions.)
|
||||
Meteor.logout(expect(function (error) {
|
||||
test.equal(error, undefined);
|
||||
@@ -122,17 +122,17 @@
|
||||
}));
|
||||
},
|
||||
function (test, expect) {
|
||||
Accounts.confirmEmail(confirmEmailToken,
|
||||
Accounts.verifyEmail(verifyEmailToken,
|
||||
waitUntilLoggedIn(test, expect));
|
||||
},
|
||||
function (test, expect) {
|
||||
test.equal(Meteor.user().emails.length, 1);
|
||||
test.equal(Meteor.user().emails[0].address, email2);
|
||||
test.isTrue(Meteor.user().emails[0].confirmed);
|
||||
test.isTrue(Meteor.user().emails[0].verified);
|
||||
},
|
||||
function (test, expect) {
|
||||
Meteor.call(
|
||||
"addEmailForTestAndConfirm", email3,
|
||||
"addEmailForTestAndVerify", email3,
|
||||
expect(function (error, result) {
|
||||
test.isFalse(error);
|
||||
}));
|
||||
@@ -141,14 +141,14 @@
|
||||
Meteor.default_connection.onQuiesce(expect(function () {
|
||||
test.equal(Meteor.user().emails.length, 2);
|
||||
test.equal(Meteor.user().emails[1].address, email3);
|
||||
test.isFalse(Meteor.user().emails[1].confirmed);
|
||||
test.isFalse(Meteor.user().emails[1].verified);
|
||||
}));
|
||||
},
|
||||
function (test, expect) {
|
||||
getConfirmEmailToken(email3, test, expect);
|
||||
getVerifyEmailToken(email3, test, expect);
|
||||
},
|
||||
function (test, expect) {
|
||||
// Log out, to test that confirmEmail logs us back in. (And if we don't
|
||||
// Log out, to test that verifyEmail logs us back in. (And if we don't
|
||||
// do that, waitUntilLoggedIn won't be able to prevent race conditions.)
|
||||
Meteor.logout(expect(function (error) {
|
||||
test.equal(error, undefined);
|
||||
@@ -156,12 +156,12 @@
|
||||
}));
|
||||
},
|
||||
function (test, expect) {
|
||||
Accounts.confirmEmail(confirmEmailToken,
|
||||
Accounts.verifyEmail(verifyEmailToken,
|
||||
waitUntilLoggedIn(test, expect));
|
||||
},
|
||||
function (test, expect) {
|
||||
test.equal(Meteor.user().emails[1].address, email3);
|
||||
test.isTrue(Meteor.user().emails[1].confirmed);
|
||||
test.isTrue(Meteor.user().emails[1].verified);
|
||||
},
|
||||
function (test, expect) {
|
||||
Meteor.logout(expect(function (error) {
|
||||
@@ -194,7 +194,7 @@
|
||||
var user = result;
|
||||
test.equal(user.emails.length, 1);
|
||||
test.equal(user.emails[0].address, email4);
|
||||
test.isFalse(user.emails[0].confirmed);
|
||||
test.isFalse(user.emails[0].verified);
|
||||
}));
|
||||
},
|
||||
function (test, expect) {
|
||||
@@ -207,7 +207,7 @@
|
||||
function (test, expect) {
|
||||
test.equal(Meteor.user().emails.length, 1);
|
||||
test.equal(Meteor.user().emails[0].address, email4);
|
||||
test.isTrue(Meteor.user().emails[0].confirmed);
|
||||
test.isTrue(Meteor.user().emails[0].verified);
|
||||
},
|
||||
function (test, expect) {
|
||||
Meteor.logout(expect(function (error) {
|
||||
@@ -222,7 +222,7 @@
|
||||
function (test, expect) {
|
||||
test.equal(Meteor.user().emails.length, 1);
|
||||
test.equal(Meteor.user().emails[0].address, email4);
|
||||
test.isTrue(Meteor.user().emails[0].confirmed);
|
||||
test.isTrue(Meteor.user().emails[0].verified);
|
||||
},
|
||||
function (test, expect) {
|
||||
Meteor.logout(expect(function (error) {
|
||||
|
||||
@@ -24,11 +24,11 @@
|
||||
return interceptedEmails[email];
|
||||
},
|
||||
|
||||
addEmailForTestAndConfirm: function (email) {
|
||||
addEmailForTestAndVerify: function (email) {
|
||||
Meteor.users.update(
|
||||
{_id: this.userId},
|
||||
{$push: {emails: {address: email, confirmed: false}}});
|
||||
Accounts.sendConfirmationEmail(this.userId, email);
|
||||
{$push: {emails: {address: email, verified: false}}});
|
||||
Accounts.sendVerificationEmail(this.userId, email);
|
||||
},
|
||||
|
||||
createUserOnServer: function (email) {
|
||||
|
||||
@@ -164,20 +164,20 @@
|
||||
});
|
||||
};
|
||||
|
||||
// Confirms a user's email address based on a token originally
|
||||
// created by Accounts.sendConfirmationEmail
|
||||
// Verifies a user's email address based on a token originally
|
||||
// created by Accounts.sendVerificationEmail
|
||||
//
|
||||
// @param token {String}
|
||||
// @param callback (optional) {Function(error|undefined)}
|
||||
Accounts.confirmEmail = function(token, callback) {
|
||||
Accounts.verifyEmail = function(token, callback) {
|
||||
if (!token)
|
||||
throw new Error("Need to pass token");
|
||||
|
||||
Meteor.call(
|
||||
"confirmEmail", token,
|
||||
"verifyEmail", token,
|
||||
function (error, result) {
|
||||
if (error || !result) {
|
||||
error = error || new Error("No result from call to confirmUser");
|
||||
error = error || new Error("No result from call to verifyEmail");
|
||||
callback && callback(error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@
|
||||
Meteor.users.update({_id: user._id, 'emails.address': email}, {
|
||||
$set: {'services.password.srp': newVerifier,
|
||||
'services.resume.loginTokens': [stampedLoginToken],
|
||||
'emails.$.confirmed': true},
|
||||
'emails.$.verified': true},
|
||||
$unset: {'services.password.reset': 1}
|
||||
});
|
||||
|
||||
@@ -134,13 +134,13 @@
|
||||
return {token: stampedLoginToken.token, id: user._id};
|
||||
},
|
||||
|
||||
confirmEmail: function (token) {
|
||||
verifyEmail: function (token) {
|
||||
if (!token)
|
||||
throw new Meteor.Error(400, "Need to pass token");
|
||||
|
||||
var user = Meteor.users.findOne({'emails.confirmationTokens.token': token});
|
||||
var user = Meteor.users.findOne({'emails.verificationTokens.token': token});
|
||||
if (!user)
|
||||
throw new Meteor.Error(403, "Confirm email link expired");
|
||||
throw new Meteor.Error(403, "Verify email link expired");
|
||||
|
||||
// Log the user in with a new login token.
|
||||
var stampedLoginToken = Accounts._generateStampedLoginToken();
|
||||
@@ -151,9 +151,9 @@
|
||||
// http://www.mongodb.org/display/DOCS/Updating/#Updating-The%24positionaloperator)
|
||||
// http://www.mongodb.org/display/DOCS/Updating#Updating-%24pull
|
||||
Meteor.users.update(
|
||||
{_id: user._id, 'emails.confirmationTokens.token': token}, {
|
||||
$set: {'emails.$.confirmed': true},
|
||||
$pull: {'emails.$.confirmationTokens': {token: token}},
|
||||
{_id: user._id, 'emails.verificationTokens.token': token}, {
|
||||
$set: {'emails.$.verified': true},
|
||||
$pull: {'emails.$.verificationTokens': {token: token}},
|
||||
$push: {'services.resume.loginTokens': stampedLoginToken}});
|
||||
|
||||
this.setUserId(user._id);
|
||||
@@ -196,8 +196,8 @@
|
||||
|
||||
|
||||
// send the user an email with a link that when opened marks that
|
||||
// address as confirmed
|
||||
Accounts.sendConfirmationEmail = function (userId, email) {
|
||||
// address as verified
|
||||
Accounts.sendVerificationEmail = function (userId, email) {
|
||||
// XXX Also generate a link using which someone can delete this
|
||||
// account if they own said address but weren't those who created
|
||||
// this account.
|
||||
@@ -206,9 +206,9 @@
|
||||
var user = Meteor.users.findOne(userId);
|
||||
if (!user)
|
||||
throw new Error("Can't find user");
|
||||
// pick the first unconfirmed email if we weren't passed an email.
|
||||
// pick the first unverified email if we weren't passed an email.
|
||||
if (!email) {
|
||||
email = _.find(user.emails || [], function (e) { return !e.confirmed; });
|
||||
email = _.find(user.emails || [], function (e) { return !e.verified; });
|
||||
email = (email || {}).address;
|
||||
}
|
||||
// make sure we have a valid email
|
||||
@@ -218,19 +218,19 @@
|
||||
|
||||
var stampedToken = {token: Meteor.uuid(), when: +(new Date)};
|
||||
Meteor.users.update({_id: userId, 'emails.address': email},
|
||||
{$push: {'emails.$.confirmationTokens': stampedToken}});
|
||||
{$push: {'emails.$.verificationTokens': stampedToken}});
|
||||
|
||||
var confirmEmailUrl = Accounts.urls.confirmEmail(stampedToken.token);
|
||||
var verifyEmailUrl = Accounts.urls.verifyEmail(stampedToken.token);
|
||||
Email.send({
|
||||
to: email,
|
||||
from: Accounts.emailTemplates.from,
|
||||
subject: Accounts.emailTemplates.confirmEmail.subject(user),
|
||||
text: Accounts.emailTemplates.confirmEmail.text(user, confirmEmailUrl)
|
||||
subject: Accounts.emailTemplates.verifyEmail.subject(user),
|
||||
text: Accounts.emailTemplates.verifyEmail.text(user, verifyEmailUrl)
|
||||
});
|
||||
};
|
||||
|
||||
// send the user an email informing them that their account was created, with
|
||||
// a link that when opened both marks their email as confirmed and forces them
|
||||
// a link that when opened both marks their email as verified and forces them
|
||||
// to choose their password. The email must be one of the addresses in the
|
||||
// user's emails field, or undefined to pick the first email automatically.
|
||||
Accounts.sendEnrollmentEmail = function (userId, email) {
|
||||
@@ -383,7 +383,7 @@
|
||||
if (username)
|
||||
user.username = username;
|
||||
if (email)
|
||||
user.emails = [{address: email, confirmed: false}];
|
||||
user.emails = [{address: email, verified: false}];
|
||||
|
||||
return Accounts.insertUserDoc(options, extra, user);
|
||||
};
|
||||
@@ -399,15 +399,15 @@
|
||||
// Create user. result contains id and token.
|
||||
var result = createUser(options, extra);
|
||||
// safety belt. createUser is supposed to throw on error. send 500 error
|
||||
// instead of sending a confirmation email with empty userid.
|
||||
// instead of sending a verification email with empty userid.
|
||||
if (!result.id)
|
||||
throw new Error("createUser failed to insert new user");
|
||||
|
||||
// If `Accounts._options.sendConfirmationEmail` is set, register
|
||||
// a token to confirm the user's primary email, and send it to
|
||||
// If `Accounts._options.sendVerificationEmail` is set, register
|
||||
// a token to verify the user's primary email, and send it to
|
||||
// that address.
|
||||
if (options.email && Accounts._options.sendConfirmationEmail)
|
||||
Accounts.sendConfirmationEmail(result.id, options.email);
|
||||
if (options.email && Accounts._options.sendVerificationEmail)
|
||||
Accounts.sendVerificationEmail(result.id, options.email);
|
||||
|
||||
// client gets logged in as the new user afterwards.
|
||||
this.setUserId(result.id);
|
||||
|
||||
@@ -28,7 +28,7 @@ Accounts.onCreateUser(function (options, extra, user) {
|
||||
// For now, we just test the one configuration state. You can comment
|
||||
// out each configuration option and see that the tests fail.
|
||||
Accounts.config({
|
||||
sendConfirmationEmail: true
|
||||
sendVerificationEmail: true
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<body>
|
||||
{{> _resetPasswordDialog}}
|
||||
{{> _enrollAccountDialog}}
|
||||
{{> _justConfirmedEmailDialog}}
|
||||
{{> _justVerifiedEmailDialog}}
|
||||
{{> _configureLoginServiceDialog}}
|
||||
|
||||
<!-- if we're not showing a dropdown, we need some other place to show messages -->
|
||||
@@ -60,11 +60,11 @@
|
||||
{{/if}}
|
||||
</template>
|
||||
|
||||
<template name="_justConfirmedEmailDialog">
|
||||
<template name="_justVerifiedEmailDialog">
|
||||
{{#if visible}}
|
||||
<div class="accounts-dialog accounts-centered-dialog">
|
||||
Email confirmed
|
||||
<div class="login-button" id="just-confirmed-dismiss-button">Dismiss</div>
|
||||
Email verified
|
||||
<div class="login-button" id="just-verified-dismiss-button">Dismiss</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</template>
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
|
||||
// Needs to be in Meteor.startup because of a package loading order
|
||||
// issue. We can't be sure that accounts-password is loaded earlier
|
||||
// than accounts-ui so Accounts.confirmEmail might not be defined.
|
||||
// than accounts-ui so Accounts.verifyEmail might not be defined.
|
||||
Meteor.startup(function () {
|
||||
if (Accounts._confirmEmailToken) {
|
||||
Accounts.confirmEmail(Accounts._confirmEmailToken, function(error) {
|
||||
if (Accounts._verifyEmailToken) {
|
||||
Accounts.verifyEmail(Accounts._verifyEmailToken, function(error) {
|
||||
Accounts._enableAutoLogin();
|
||||
if (!error)
|
||||
loginButtonsSession.set('justConfirmedEmail', true);
|
||||
loginButtonsSession.set('justVerifiedEmail', true);
|
||||
// XXX show something if there was an error.
|
||||
});
|
||||
}
|
||||
@@ -116,17 +116,17 @@
|
||||
|
||||
|
||||
//
|
||||
// justConfirmedEmailDialog template
|
||||
// justVerifiedEmailDialog template
|
||||
//
|
||||
|
||||
Template._justConfirmedEmailDialog.events({
|
||||
'click #just-confirmed-dismiss-button': function () {
|
||||
loginButtonsSession.set('justConfirmedEmail', false);
|
||||
Template._justVerifiedEmailDialog.events({
|
||||
'click #just-verified-dismiss-button': function () {
|
||||
loginButtonsSession.set('justVerifiedEmail', false);
|
||||
}
|
||||
});
|
||||
|
||||
Template._justConfirmedEmailDialog.visible = function () {
|
||||
return loginButtonsSession.get('justConfirmedEmail');
|
||||
Template._justVerifiedEmailDialog.visible = function () {
|
||||
return loginButtonsSession.get('justVerifiedEmail');
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
'resetPasswordToken',
|
||||
'enrollAccountToken',
|
||||
'justConfirmedEmail',
|
||||
'justVerifiedEmail',
|
||||
|
||||
'configureLoginServiceDialogVisible',
|
||||
'configureLoginServiceDialogServiceName',
|
||||
|
||||
@@ -263,7 +263,7 @@ out-of-the-box in more apps.
|
||||
float: right;
|
||||
}
|
||||
|
||||
#just-confirmed-dismiss-button, #messages-dialog-dismiss-button {
|
||||
#just-verified-dismiss-button, #messages-dialog-dismiss-button {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Package.describe({
|
||||
summary: "Generate and consume reset password and confirm account URLs",
|
||||
summary: "Generate and consume reset password and verify account URLs",
|
||||
internal: true
|
||||
});
|
||||
|
||||
|
||||
@@ -18,20 +18,20 @@
|
||||
window.location.hash = '';
|
||||
}
|
||||
|
||||
// reads a confirm email token from the url's hash fragment, if
|
||||
// reads a verify email token from the url's hash fragment, if
|
||||
// it's there. also don't automatically log the user is, as for
|
||||
// reset password links.
|
||||
//
|
||||
// XXX we don't need to use hash fragments in this case, and having
|
||||
// the token appear in the url's path would allow us to use a custom
|
||||
// middleware instead of confirming the email on pageload, which
|
||||
// middleware instead of verifying the email on pageload, which
|
||||
// would be faster but less DDP-ish (and more specifically, any
|
||||
// non-web DDP app, such as an iOS client, would do something more
|
||||
// in line with the hash fragment approach)
|
||||
match = window.location.hash.match(/^\#\/confirm-email\/(.*)$/);
|
||||
match = window.location.hash.match(/^\#\/verify-email\/(.*)$/);
|
||||
if (match) {
|
||||
Accounts._preventAutoLogin = true;
|
||||
Accounts._confirmEmailToken = match[1];
|
||||
Accounts._verifyEmailToken = match[1];
|
||||
window.location.hash = '';
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ Accounts.urls.resetPassword = function (token) {
|
||||
return Meteor.absoluteUrl('#/reset-password/' + token);
|
||||
};
|
||||
|
||||
Accounts.urls.confirmEmail = function (token) {
|
||||
return Meteor.absoluteUrl('#/confirm-email/' + token);
|
||||
Accounts.urls.verifyEmail = function (token) {
|
||||
return Meteor.absoluteUrl('#/verify-email/' + token);
|
||||
};
|
||||
|
||||
Accounts.urls.enrollAccount = function (token) {
|
||||
|
||||
Reference in New Issue
Block a user