0
私のアプリケーションで認証のためのプロバイダ - AuthHelperProvider
があります。ユーザーがログインに失敗したときは、ログインボタンを無効にする必要があります。この目的のために私は私のプロバイダでイベントを公開し、LoginPage
コンポーネントにサブスクライブ:イオン2適切な方法イベントを使用する
AuthHelperProvider
this.http.get(query).map(res => <{error: string, clientId: string}>res.json()).subscribe(response => {
if (response.error == '') {
console.log(this.TAG + 'log in without errors');
if (keepSingIn) {
this.storage.set(this.KEEP_LOGGED_IN, true);
this.setUsername(login);
this.setPassword(password);
}
this.setClientId(response.clientId);
this.events.publish('user:login');
this.attemptCount = 0;
/*this.navCtrl.setRoot(TabsPage);*/
} else {
console.log(this.TAG + 'log in with errors' + response.error);
this.events.publish('user:failedAttempt',++this.attemptCount);
this.errorHelper.showErrorAlert(response.error);
}
});
LoginPage
this.events.subscribe('user:failedAttempt', (attemptsCount) => {
console.log(this.TAG + 'number of failed attempts: ' + attemptsCount);
if (attemptsCount >= 3) {
this.isLoginBlocked = true;
this.errorAlert.showErrorToast('Number of attempts exceeded, try to restore your account');
} else {
this.isLoginBlocked = false;
}
});
しかし、私は予期しない動作に会った:ハンドラをサブスクライブするためにattemptsCount
回と呼ばれるイベント。それは馬鹿に見えますが、何が間違っていますか?
をこんにちは、私はちょうど私の間違った答えを削除した、あなたはおそらくその答えにあなたの調査結果を追加する必要がありますし、スレッドがあるので、数日で、それを受け入れますQ&Aを完了してください。 –