本文整理汇总了Java中com.google.firebase.auth.ProviderQueryResult类的典型用法代码示例。如果您正苦于以下问题:Java ProviderQueryResult类的具体用法?Java ProviderQueryResult怎么用?Java ProviderQueryResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProviderQueryResult类属于com.google.firebase.auth包,在下文中一共展示了ProviderQueryResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkAccountEmailExistsInFirebase
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
private void checkAccountEmailExistsInFirebase(final String email) {
if(!validateEmail()) return;
mProgressDialog.setTitle("Resetting Password");
mProgressDialog.setMessage("Please wait while we send password reset email.");
mProgressDialog.setCanceledOnTouchOutside(false);
mProgressDialog.show();
mFirebaseAuth = FirebaseAuth.getInstance();
mFirebaseAuth.fetchProvidersForEmail(email).addOnCompleteListener(new OnCompleteListener<ProviderQueryResult>() {
@Override
public void onComplete(@NonNull Task<ProviderQueryResult> task) {
//Log.d(TAG, "checking email exists.");
if(task.getResult().getProviders() != null){
resetPassword(task.getResult().getProviders(), email);
}
}
});
}
示例2: checkAccountEmailExistsInFirebase
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
public void checkAccountEmailExistsInFirebase(final String email) {
FirebaseApp.initializeApp(this);
FirebaseAuth mAuth = FirebaseAuth.getInstance();
mAuth.fetchProvidersForEmail(email).addOnCompleteListener(new OnCompleteListener<ProviderQueryResult>() {
@Override
public void onComplete(@NonNull Task<ProviderQueryResult> task) {
if((task.getResult().getProviders() != null && task.getResult().getProviders().isEmpty())){
signUpUser(email);
}else{
mProgressDialog.dismiss();
Snackbar.make(mConstraintLayout, "Account with Email Address Already Exists.", Snackbar.LENGTH_LONG ).show();
}
}
});
}
示例3: fetchProvidersForEmail
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
@Test
public void fetchProvidersForEmail() throws InterruptedException {
TestSubscriber<ProviderQueryResult> testSubscriber = new TestSubscriber<>();
RxFirebaseAuth.fetchProvidersForEmail(mockAuth, "email")
.subscribeOn(Schedulers.immediate())
.subscribe(testSubscriber);
testOnSuccessListener.getValue().onSuccess(mockProviderQueryResult);
testOnCompleteListener.getValue().onComplete(mockProviderQueryResultTask);
verify(mockAuth).fetchProvidersForEmail(eq("email"));
testSubscriber.assertNoErrors();
testSubscriber.assertValueCount(1);
testSubscriber.assertReceivedOnNext(Collections.singletonList(mockProviderQueryResult));
testSubscriber.assertCompleted();
testSubscriber.unsubscribe();
}
示例4: fetchProvidersForEmail
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
@Test
public void fetchProvidersForEmail() throws InterruptedException {
TestObserver<ProviderQueryResult> authTestObserver = RxFirebaseAuth
.fetchProvidersForEmail(firebaseAuth, ANY_EMAIL)
.test();
testOnSuccessListener.getValue().onSuccess(providerQueryResult);
testOnCompleteListener.getValue().onComplete(providerQueryResultTask);
verify(firebaseAuth).fetchProvidersForEmail(eq(ANY_EMAIL));
authTestObserver.assertNoErrors()
.assertValueCount(1)
.assertValueSet(Collections.singletonList(providerQueryResult))
.assertComplete()
.dispose();
}
示例5: fetchProvidersForEmail
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
/**
* TODO: Should use Maybe instead of Single
* TODO: flatten List
*
* @param instance
* @param email
* @return <emptyList> if providers is null
*/
@CheckReturnValue
@NonNull
public static Single<List<String>> fetchProvidersForEmail(
@NonNull final FirebaseAuth instance, @NonNull final String email) {
return RxTask.single(new Callable<Task<ProviderQueryResult>>() {
@Override
public Task<ProviderQueryResult> call() throws Exception {
return instance.fetchProvidersForEmail(email);
}
}).map(new Function<ProviderQueryResult, List<String>>() {
@Override
public List<String> apply(@NonNull ProviderQueryResult providerQueryResult)
throws Exception {
List<String> providers = providerQueryResult.getProviders();
if (null == providers) {
providers = Collections.emptyList();
}
return providers;
}
});
}
示例6: fetchTopProvider
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
public static Task<String> fetchTopProvider(FirebaseAuth auth, @NonNull String email) {
if (TextUtils.isEmpty(email)) {
return Tasks.forException(new NullPointerException("Email cannot be empty"));
}
return auth.fetchProvidersForEmail(email)
.continueWith(new Continuation<ProviderQueryResult, String>() {
@Override
public String then(@NonNull Task<ProviderQueryResult> task) {
if (!task.isSuccessful()) return null;
List<String> providers = task.getResult().getProviders();
return providers == null || providers.isEmpty()
? null : providers.get(providers.size() - 1);
}
});
}
示例7: fetchProvidersForEmail
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
/**
* Gets the list of provider IDs that can be used to sign in for the given email address. Useful for an "identifier-first" sign-in flow.
*
* @param firebaseAuth firebaseAuth instance.
* @param email An email address.
* @return a {@link Maybe} which emits an {@link ProviderQueryResult} if success.
* @see <a href="https://firebase.google.com/docs/reference/android/com/google/firebase/auth/FirebaseAuth">Firebase Auth API</a>
*/
@NonNull
public static Maybe<ProviderQueryResult> fetchProvidersForEmail(@NonNull final FirebaseAuth firebaseAuth,
@NonNull final String email) {
return Maybe.create(new MaybeOnSubscribe<ProviderQueryResult>() {
@Override
public void subscribe(MaybeEmitter<ProviderQueryResult> emitter) throws Exception {
RxHandler.assignOnTask(emitter, firebaseAuth.fetchProvidersForEmail(email));
}
});
}
示例8: subscribe
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
@Override public void subscribe(final MaybeEmitter<List<String>> emitter) {
final OnCompleteListener<ProviderQueryResult> listener =
new OnCompleteListener<ProviderQueryResult>() {
@Override public void onComplete(@NonNull Task<ProviderQueryResult> task) {
if (!task.isSuccessful()) {
if (!emitter.isDisposed()) {
emitter.onError(task.getException());
}
return;
}
if (!emitter.isDisposed()) {
ProviderQueryResult result = task.getResult();
if (result != null) {
List<String> providers = result.getProviders();
if (providers != null) {
emitter.onSuccess(providers);
return;
}
}
emitter.onComplete();
}
}
};
instance.fetchProvidersForEmail(email).addOnCompleteListener(listener);
}
示例9: fetchProvidersForEmail
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
@NonNull
public static Observable<ProviderQueryResult> fetchProvidersForEmail(@NonNull final FirebaseAuth firebaseAuth,
@NonNull final String email) {
return Observable.create(new Observable.OnSubscribe<ProviderQueryResult>() {
@Override
public void call(final Subscriber<? super ProviderQueryResult> subscriber) {
RxHandler.assignOnTask(subscriber, firebaseAuth.fetchProvidersForEmail(email));
}
});
}
示例10: fetchProvidersForEmailError
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
@Test
public void fetchProvidersForEmailError() throws InterruptedException {
TestObserver<ProviderQueryResult> authTestObserver = RxFirebaseAuth
.fetchProvidersForEmail(firebaseAuth, ANY_EMAIL)
.test();
testOnFailureListener.getValue().onFailure(EXCEPTION);
verify(firebaseAuth).fetchProvidersForEmail(ANY_EMAIL);
authTestObserver.assertError(EXCEPTION)
.assertNotComplete()
.dispose();
}
示例11: mockSuccessfulFetchProvidersResult
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
private void mockSuccessfulFetchProvidersResult() {
when(mockFetchProvidersTask.isSuccessful())
.thenReturn(true);
ProviderQueryResult result = mock(ProviderQueryResult.class);
when(result.getProviders())
.thenReturn(new ArrayList<String>());
when(mockFetchProvidersTask.getResult())
.thenReturn(result);
//noinspection unchecked
when(mockFetchProvidersTask.addOnCompleteListener(onComplete.capture()))
.thenReturn(mockFetchProvidersTask);
}
示例12: fetchProvidersForEmail
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
@CheckResult
public Single<ProviderQueryResult> fetchProvidersForEmail(String email) {
return RxTasks.single(auth.fetchProvidersForEmail(email));
}
示例13: fetchProvidersForEmail
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
@Override
public Task<ProviderQueryResult> fetchProvidersForEmail(String email) {
return mAuth.fetchProvidersForEmail(email);
}
示例14: testSignInFailed_withFacebookAlreadyLinked
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
@Test
@Config(shadows = {AuthHelperShadow.class})
public void testSignInFailed_withFacebookAlreadyLinked() {
AppCompatBase mockActivity = mock(AppCompatBase.class);
IdpResponse idpResponse =
new IdpResponse.Builder(
new User.Builder(GoogleAuthProvider.PROVIDER_ID, TestConstants.EMAIL)
.build())
.setToken(TestConstants.TOKEN)
.build();
CredentialSignInHandler credentialSignInHandler = new CredentialSignInHandler(
mockActivity,
null,
RC_ACCOUNT_LINK,
idpResponse);
FlowParameters mockFlowParams = mock(FlowParameters.class);
when(mockActivity.getFlowParams()).thenReturn(mockFlowParams);
AuthHelper mockAuthHelper = mock(AuthHelper.class);
when(mockActivity.getAuthHelper()).thenReturn(mockAuthHelper);
AuthHelperShadow.getFirebaseAuth(); // Force static initialization
when(mockAuthHelper.getFirebaseAuth()).thenReturn(AuthHelperShadow.getFirebaseAuth());
ProgressDialogHolder mockHolder = mock(ProgressDialogHolder.class);
when(mockActivity.getDialogHolder()).thenReturn(mockHolder);
// pretend the account has Facebook linked already
when(AuthHelperShadow.getFirebaseAuth().fetchProvidersForEmail(TestConstants.EMAIL)).thenReturn(
new AutoCompleteTask<ProviderQueryResult>(
new FakeProviderQueryResult(
Arrays.asList(FacebookAuthProvider.PROVIDER_ID)), true, null));
// pretend there was already an account with this email
Task<AuthResult> exceptionTask = Tasks.forException(
new FirebaseAuthUserCollisionException(LINKING_ERROR, LINKING_EXPLANATION));
credentialSignInHandler.onComplete(exceptionTask);
ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
ArgumentCaptor<Integer> intCaptor = ArgumentCaptor.forClass(Integer.class);
verify(mockActivity).startActivityForResult(intentCaptor.capture(), intCaptor.capture());
Intent capturedIntent = intentCaptor.getValue();
User capturedUser = User.getUser(capturedIntent);
assertEquals(RC_ACCOUNT_LINK, (int) intCaptor.getValue());
assertEquals(
WelcomeBackIdpPrompt.class.getName(),
capturedIntent.getComponent().getClassName());
assertEquals(
TestConstants.EMAIL,
capturedUser.getEmail());
assertEquals(
FacebookAuthProvider.PROVIDER_ID,
capturedUser.getProviderId());
}
示例15: testSignInFailed_withPasswordAccountAlreadyLinked
import com.google.firebase.auth.ProviderQueryResult; //导入依赖的package包/类
@Test
@Config(shadows = {AuthHelperShadow.class})
public void testSignInFailed_withPasswordAccountAlreadyLinked() {
AppCompatBase mockActivity = mock(AppCompatBase.class);
IdpResponse idpResponse =
new IdpResponse.Builder(
new User.Builder(GoogleAuthProvider.PROVIDER_ID, TestConstants.EMAIL)
.build())
.setToken(TestConstants.TOKEN)
.build();
CredentialSignInHandler credentialSignInHandler = new CredentialSignInHandler(
mockActivity,
null,
RC_ACCOUNT_LINK,
idpResponse);
FlowParameters mockFlowParams = mock(FlowParameters.class);
when(mockActivity.getFlowParams()).thenReturn(mockFlowParams);
AuthHelper mockAuthHelper = mock(AuthHelper.class);
when(mockActivity.getAuthHelper()).thenReturn(mockAuthHelper);
AuthHelperShadow.getFirebaseAuth(); // Force static initialization
when(mockAuthHelper.getFirebaseAuth()).thenReturn(AuthHelperShadow.getFirebaseAuth());
ProgressDialogHolder mockHolder = mock(ProgressDialogHolder.class);
when(mockActivity.getDialogHolder()).thenReturn(mockHolder);
// pretend there was already an account with this email
Task mockTask = mock(Task.class);
when(mockTask.getException()).thenReturn(
new FirebaseAuthUserCollisionException(LINKING_ERROR, LINKING_EXPLANATION));
// pretend the account has a Password account linked already
when(AuthHelperShadow.getFirebaseAuth().fetchProvidersForEmail(TestConstants.EMAIL)).thenReturn(
new AutoCompleteTask<ProviderQueryResult>(
new FakeProviderQueryResult(
Arrays.asList(EmailAuthProvider.PROVIDER_ID)), true, null));
credentialSignInHandler.onComplete(mockTask);
ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
ArgumentCaptor<Integer> intCaptor = ArgumentCaptor.forClass(Integer.class);
verify(mockActivity).startActivityForResult(intentCaptor.capture(), intCaptor.capture());
Intent capturedIntent = intentCaptor.getValue();
assertEquals(RC_ACCOUNT_LINK, (int) intCaptor.getValue());
assertEquals(
WelcomeBackPasswordPrompt.class.getName(),
capturedIntent.getComponent().getClassName());
assertEquals(
TestConstants.EMAIL,
IdpResponse.fromResultIntent(capturedIntent).getEmail());
}