本文整理汇总了TypeScript中lib/tylogger.LogDB函数的典型用法代码示例。如果您正苦于以下问题:TypeScript LogDB函数的具体用法?TypeScript LogDB怎么用?TypeScript LogDB使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LogDB函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: changeEmail
export function changeEmail(uid, mail){
try{
if(!mail || !validateEmail(mail)){
//throw new Error("无效邮件地址.");
return "无效邮件地址!"
}
let user = Meteor.users.findOne({_id: uid})
var oldmail = _.find(user.emails || [],
function (e) { return e.address; });
let address = (oldmail || {}).address;
LogDebug(address, mail)
if(address && address == mail){
return 'mail is unchanged'
}
if(address){
Accounts.removeEmail(uid, address)
}
Accounts.addEmail(uid, mail)
return 'ok'
}catch(err){
LogDB(err.toString(), 'changeEmail()', uid)
return err.toString()
}
}
示例2: function
upsertRecord: function(record: YiRecord){
try{
BkRecords.upsert(record)
}catch(err){
LogDB(err.toString(), record, this.userId)
}
}
示例3: sendResetPasswordEmail
export function sendResetPasswordEmail (userId, email) {
try{
// Make sure the user exists, and email is one of their addresses.
var user = Meteor.users.findOne(userId);
if (!user)
throw new Error("Can't find user");
// pick the first email if we weren't passed an email.
if (!email && user.emails && user.emails[0])
email = user.emails[0].address;
// make sure we have a valid email
if (!email || !_.contains(_.pluck(user.emails || [], 'address'), email))
throw new Error("No such email for user.");
var tokenRecord = {
token: RandomStr(44),
email: email,
when: new Date()
};
Meteor.users.update(userId, {$set: {
"services.password.reset": tokenRecord
}});
// before passing to template, update user object with new token
Meteor._ensure(user, 'services', 'password').reset = tokenRecord;
var mailbody = writeResetPasswordEmail(email, tokenRecord.token, user.username)
return mailbody;
}catch(err){
LogDB(err.toString(), 'sendResetPasswordEmail()', userId)
return err.toString()
}
};
示例4: function
Meteor.publish('bkrecord', function(bookid: string, options: Object) {
try{
return BkRecords.find(buildQuery.call(this, bookid), options);
}catch(err){
LogDB(err.toString(), options, 'publish: ' + bookid)
return null
}
});
示例5: validateEmail
function validateEmail(email) {
try{
var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
//var re = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
return re.test(email);
}catch(err){
LogDB(err.toString(), 'validateEmail()', this.userId)
return false
}
}
示例6: verificationMail
export function verificationMail(uid, address): Object{
try{
// Make sure the user exists, and address is one of their addresses.
var user = Meteor.users.findOne({_id: uid});
if (!user){
//throw new Error("Can't find user");
LogDebug('Cannot find user')
return null
}
// pick the first unverified address if we weren't passed an address.
if (!address) {
var email = _.find(user.emails || [],
function (e) { return !e.verified; });
address = (email || {}).address;
}
// make sure we have a valid address
if (!address || !_.contains(_.pluck(user.emails || [], 'address'), address)){
//throw new Error("No such email address for user.");
LogDebug('no email')
return null
}
var tokenRecord = {
token: RandomStr(44),
address: address,
when: new Date()
};
Meteor.users.update({_id: uid}, {$push: {'services.email.verificationTokens': tokenRecord}});
// before passing to template, update user object with new token
Meteor._ensure(user, 'services', 'email');
if (!user.services.email.verificationTokens) {
user.services.email.verificationTokens = [];
}
user.services.email.verificationTokens.push(tokenRecord);
//var verifyEmailUrl = Accounts.urls.verifyEmail(tokenRecord.token);
var mailbody = writeVerifyEmail(address, tokenRecord.token, user.username)
return mailbody;
}catch(err){
LogDB(err.toString(), 'verificationMail()', uid)
return null
}
}