本文整理匯總了TypeScript中common-app.Credentials類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Credentials類的具體用法?TypeScript Credentials怎麽用?TypeScript Credentials使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Credentials類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Promise
return new Promise((resolve, reject) => {
console.debug("Creating user:" + JSON.stringify(credentials));
credentials.saveCredentials();
this.firebase.auth().createUserWithEmailAndPassword(
credentials.username,
credentials.password
).catch((error) => {
this.handleError(error);
}).then((fbUser: firebase.User) => {
if (fbUser) {
let user = transformUser(fbUser);
saveUserProfile(this.firebase.database(), user)
.then(() => {
resolve(
LoginActions.loginSuccessFactory(user, user._id)
);
})
.catch((error) => {
this.handleError(error);
reject(error);
});
console.info('Create User successful.');
}
});
});
示例2: Promise
return new Promise((resolve, reject) => {
credentials.saveCredentials();
console.log(Meteor);
Meteor.loginWithPassword(
credentials.email ? credentials.email : credentials.username, credentials.password,
(error) => {
if (error) {
console.info(error);
reject(ReduxModuleUtil.errorFactory(LoginActions.LOGIN_ERROR, error));
} else {
console.info('Login successful.');
resolve(
LoginActions.loginSuccessFactory(
this.userFromMeteorUser(Meteor.user()), Meteor.userId(), false
)
);
}
});
})