本文整理匯總了TypeScript中server/agents/account-agent.add函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript add函數的具體用法?TypeScript add怎麽用?TypeScript add使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了add函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: async
test.serial('パスワード変更の入力値検証 - メールアドレス以外に認証手段がある時はパスワードなしに変更できること', async (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
let account : Account =
{
email: 'admin@example.com',
password: '12345678',
twitter: 'twitter'
};
account.password = Utils.getHashPassword(account.email, account.password, Config.PASSWORD_SALT);
account = await AccountAgent.add(account);
const param : Request.ChangePassword =
{
oldPassword: '12345678',
newPassword: null,
confirm: null,
};
const result = await isChangePasswordValid(param, account.id, locale);
const {status} = result.response;
t.is(status, Response.Status.OK);
await AccountAgent.remove(account.id);
log.stepOut();
});
示例2: execInvite
/**
* 実行
*/
async function execInvite(param : Request.Invite, locale : string) : Promise<Response.Invite>
{
const log = slog.stepIn('SettingsApi', 'execInvite');
const response : Response.Invite = {status:Response.Status.FAILED, message:{}};
const {email} = param;
const invite_id = Utils.createRandomText(32);
const url = Utils.generateUrl('join', invite_id);
const template = R.mail(R.NOTICE_INVITE, locale);
const contents = CommonUtils.formatString(template.contents, {url});
const result = await Utils.sendMail(template.subject, email, contents);
if (result)
{
response.status = Response.Status.OK;
response.message.general = R.text(R.INVITE_MAIL_SENDED, locale);
const name = email.substr(0, email.indexOf('@'));
const account : Account = {name, email, invite_id};
await AccountAgent.add(account);
}
else
{
response.message.email = R.text(R.COULD_NOT_SEND_INVITE_MAIL, locale);
}
log.stepOut();
return response;
}