当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Accounts.config方法代码示例

本文整理汇总了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
    });
});
开发者ID:yk,项目名称:damgr,代码行数:7,代码来源:main.ts

示例2:

Meteor.startup(() => {
    Teams.find().count();
    IncompleteTeams.find().count();
    Submissions.find().count();

    Accounts.config({
        forbidClientAccountCreation: true
    });
    //console.log(LDAP_DEFAULTS);
});
开发者ID:yk,项目名称:kethlle,代码行数:10,代码来源:main.ts

示例3: Init

export function Init() {
	Accounts.config({
		sendVerificationEmail: true,
		restrictCreationByEmailDomain: 'azahner.com'
	});
}
开发者ID:twastvedt,项目名称:barbatus-typescript-bug-demo,代码行数:6,代码来源:Init.ts

示例4: function

export default function() {
  Accounts.config({
    sendVerificationEmail: false
  });
};
开发者ID:tomitrescak,项目名称:Marking,代码行数:5,代码来源:accounts.ts

示例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
    }
//.........这里部分代码省略.........
开发者ID:tomitrescak,项目名称:meteor-accountsui-semanticui-react,代码行数:101,代码来源:accounts.ts

示例6:

import { Accounts } from 'meteor/accounts-base';

Accounts.config({
  sendVerificationEmail: false,
  forbidClientAccountCreation: false
});
开发者ID:TribeMedia,项目名称:meteor-mantra-redux-graphql,代码行数:6,代码来源:accounts.ts


注:本文中的meteor/accounts-base.Accounts.config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。