當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。