本文整理汇总了TypeScript中meteor/accounts-base.Accounts.config方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Accounts.config方法的具体用法?TypeScript Accounts.config怎么用?TypeScript Accounts.config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meteor/accounts-base.Accounts
的用法示例。
在下文中一共展示了Accounts.config方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
Meteor.startup(() => {
ShopItems.find().count();
Accounts.config({
forbidClientAccountCreation: true
});
});
示例2:
Meteor.startup(() => {
Teams.find().count();
IncompleteTeams.find().count();
Submissions.find().count();
Accounts.config({
forbidClientAccountCreation: true
});
//console.log(LDAP_DEFAULTS);
});
示例3: Init
export function Init() {
Accounts.config({
sendVerificationEmail: true,
restrictCreationByEmailDomain: 'azahner.com'
});
}
示例4: function
export default function() {
Accounts.config({
sendVerificationEmail: false
});
};
示例5: function
export default function() {
Meteor.methods({
sendVerification: function(email: string) {
check(email, String);
let user = Meteor.users.findOne({
"emails.address": email
});
if (!user) {
throw new Meteor.Error(403, "User not found");
}
if (user.emails[0].verified) {
throw new Meteor.Error(403, "User already verified");
}
console.log("Sending verification email to: " + user.emails[0].address);
return Accounts.sendVerificationEmail(user._id);
},
addUser: function(data: any) {
check(data, {
email: String,
password: String,
profile: Match.Any
});
// TODO: Roles
let userId = Accounts.createUser({
email: data.email,
password: data.password,
profile: data.profile
});
if (!userId) {
throw new Error("createUser failed to insert new user");
}
// If `Accounts._options.sendVerificationEmail` is set, register
// a token to verify the user"s primary email, and send it to
// that address.
Accounts.sendVerificationEmail(userId);
}
});
// configs
// By default, the email is sent from no-reply@meteor.com. If you wish to receive email from users asking for
// help with their account, be sure to set this to an email address that you can receive email at.
const config = {
siteName: "Boilerplate",
from: "tomi.trescak@gmail.com",
accounts: {
subject: "Please verify your email",
body: `Hello \${user},<br />
<br />
To verify your account email, simply click the link below.<br />
<br />
<a href="\${url}">\${url}</a><br />
<br />
Truly yours,<br />
Site Admin`
}
};
Accounts.emailTemplates.from = config.from;
// The public name of your application. Defaults to the DNS name of the application (eg: awesome.meteor.com).
Accounts.emailTemplates.siteName = config.siteName;
// A Function that takes a user object and returns a String for the subject line of the email.
Accounts.emailTemplates.enrollAccount.subject =
Accounts.emailTemplates.verifyEmail.subject = function(user: Meteor.User): string {
return config.accounts.subject
.replace("${user}", user.profile.name)
.replace("${siteName}", Accounts.emailTemplates.siteName);
};
// A Function that takes a user object and a url, and returns the body text for the email.
// Note: if you need to return HTML instead, use Accounts.emailTemplates.verifyEmail.html
Accounts.emailTemplates.enrollAccount.html =
Accounts.emailTemplates.verifyEmail.html = function(user: Meteor.User, url: string): string {
return config.accounts.body
.replace("${siteName}", Accounts.emailTemplates.siteName)
.replace(/\$\{url\}/g, url)
.replace(/\$\{user\}/g, user.profile.name);
};
Accounts.config({
sendVerificationEmail: true,
// restrictCreationByEmailDomain: function(email: string) {
// let domain = email.slice(email.lastIndexOf("@") + 1); // or regex
// let exists = Sites.findOne({ accounts: domain });
// return exists;
// },
forbidClientAccountCreation: true
});
Accounts.validateLoginAttempt(function(attempt: any) {
if (attempt.user && attempt.user.emails && !attempt.user.emails[0].verified) {
return false; // the login is aborted
}
//.........这里部分代码省略.........
示例6:
import { Accounts } from 'meteor/accounts-base';
Accounts.config({
sendVerificationEmail: false,
forbidClientAccountCreation: false
});