本文整理匯總了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
}
}