私はIonic2 rc4とFirebase認証を使用しています。 signupFirebaseUser()
に電話すると、期待通りにuid
が記録されます。しかし、私はloginGoogle()
を呼び出すと、別のuid
を記録すると予想されますが、同じuid
が出力されます。Firebaseログイン - uidをリセットするには?
これにより、ユーザーは、email address
とpassword
を使ってログインログアウトし、それが彼らの古いuid
を維持したいので、自分のGoogleアカウント(別のメールアドレス)でログインし直すことができないことを意味します。
signupFirebaseUser(email: string, password: string): firebase.Promise<any> {
return this.fireAuth.createUserWithEmailAndPassword(email, password).then((newUser: firebase.User) => {
console.log(newUser.uid);
this.userProfile.child(newUser.uid).set({ email: email });
newUser.sendEmailVerification();
});
}
その後、
public logout(auth: FirebaseAuth, fireAuth: firebase.auth.Auth): Promise<any> {
return auth.logout().then(() => {
fireAuth.signOut().then(() => {
});
});
}
その後、
loginGoogle() {
this.auth.login({
provider: AuthProviders.Google,
method: AuthMethods.Popup
}).then((data: FirebaseAuthState) => {
console.log(data.uid);
}).catch((error) => {
console.error('loginGoogle', error);
});
}
質問
はどのように古いuid
を忘れFirebase認証をリセットするのですか?そのため、再度ログインするときれいなスタートからそうすることができます。
つまり、プロバイダ(Google、Facebook、メール)ごとに新しいuid
を生成します。
助けてください。
1つの方法は、user.delete()を使用してユーザーを削除してから、新しいUIDを自動的に作成することです – AndroidBeginner
はい、正しく動作します。しかし、古いユーザーとして再度ログインしたい(つまり、ユーザーを交換し続ける)場合はどうなりますか?私は各ユーザーに対してデータを保存するため、アカウントを削除したくありません。 – Richard
申し訳ありませんが、問題を誤解しています。 Googleログイン用の新しいFirebase Auth APIをお試しいただけますか? (https://firebase.google.com/docs/auth/web/google-signin)。 Cordovaサポートが必要な場合は、OAuthプラグイン(https://github.com/nraboy/ng-cordova-oauthなど)を使用して、返されたアクセストークンでsignInWithCredential()を呼び出すことができます。 –