当前位置: 首页>>代码示例>>Java>>正文


Java EmailAuthProvider.getCredential方法代码示例

本文整理汇总了Java中com.google.firebase.auth.EmailAuthProvider.getCredential方法的典型用法代码示例。如果您正苦于以下问题:Java EmailAuthProvider.getCredential方法的具体用法?Java EmailAuthProvider.getCredential怎么用?Java EmailAuthProvider.getCredential使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.firebase.auth.EmailAuthProvider的用法示例。


在下文中一共展示了EmailAuthProvider.getCredential方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reauthenticate

import com.google.firebase.auth.EmailAuthProvider; //导入方法依赖的package包/类
private void reauthenticate() {
    // [START reauthenticate]
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();

    // Get auth credentials from the user for re-authentication. The example below shows
    // email and password credentials but there are multiple possible providers,
    // such as GoogleAuthProvider or FacebookAuthProvider.
    AuthCredential credential = EmailAuthProvider
            .getCredential("[email protected]", "password1234");

    // Prompt the user to re-provide their sign-in credentials
    user.reauthenticate(credential)
            .addOnCompleteListener(new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    Log.d(TAG, "User re-authenticated.");
                }
            });
    // [END reauthenticate]
}
 
开发者ID:firebase,项目名称:snippets-android,代码行数:21,代码来源:MainActivity.java

示例2: validate

import com.google.firebase.auth.EmailAuthProvider; //导入方法依赖的package包/类
private void validate() {
    String passwordText = passwordEntry.getText().toString();

    if (TextUtils.isEmpty(passwordText)) {
        passwordEntry.setError(getString(R.string.error_field_required));
        return;
    }

    if (user.getEmail() != null) {
        AuthCredential credential = EmailAuthProvider.getCredential(user.getEmail(), passwordText);

        user.reauthenticate(credential).addOnSuccessListener(new OnSuccessListener<Void>() {
            @Override
            public void onSuccess(Void aVoid) {
                System.out.println("Re-authenticated");
                user.delete();
                dismiss();
            }
        });
    }
}
 
开发者ID:STUDIO-apps,项目名称:GeoShare_Android,代码行数:22,代码来源:DeleteUser.java

示例3: validate

import com.google.firebase.auth.EmailAuthProvider; //导入方法依赖的package包/类
private void validate() {
    final String oldPasswordText = oldPasswordEntry.getText().toString();
    final String newPasswordText = newPasswordEntry.getText().toString();
    final String confirmPasswordText = confirmPasswordEntry.getText().toString();

    if (TextUtils.isEmpty(oldPasswordText)) {
        oldPasswordEntry.setError(getString(R.string.error_field_required));
        return;
    }

    if (TextUtils.isEmpty(newPasswordText)) {
        newPasswordEntry.setError(getString(R.string.error_field_required));
        return;
    }

    if (TextUtils.isEmpty(confirmPasswordText)) {
        confirmPasswordEntry.setError(getString(R.string.error_field_required));
        return;
    }

    if (!newPasswordText.equals(confirmPasswordText)) {
        confirmPasswordEntry.setError(getString(R.string.error_field_required));
        return;
    }

    if (user.getEmail() != null) {
        AuthCredential credential = EmailAuthProvider.getCredential(user.getEmail(), oldPasswordText);

        user.reauthenticate(credential).addOnSuccessListener(new OnSuccessListener<Void>() {
            @Override
            public void onSuccess(Void aVoid) {
                System.out.println("Re-authenticated");
                updatePassword(newPasswordText);
            }
        });
    }
}
 
开发者ID:STUDIO-apps,项目名称:GeoShare_Android,代码行数:38,代码来源:ChangePasswordDialog.java

示例4: linkAccount

import com.google.firebase.auth.EmailAuthProvider; //导入方法依赖的package包/类
private void linkAccount() {
    // Make sure form is valid
    if (!validateLinkForm()) {
        return;
    }

    // Get email and password from form
    String email = mEmailField.getText().toString();
    String password = mPasswordField.getText().toString();

    // Create EmailAuthCredential with email and password
    AuthCredential credential = EmailAuthProvider.getCredential(email, password);

    // Link the anonymous user to the email credential
    showProgressDialog();

    // [START link_credential]
    mAuth.getCurrentUser().linkWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        Log.d(TAG, "linkWithCredential:success");
                        FirebaseUser user = task.getResult().getUser();
                        updateUI(user);
                    } else {
                        Log.w(TAG, "linkWithCredential:failure", task.getException());
                        Toast.makeText(AnonymousAuthActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                        updateUI(null);
                    }

                    // [START_EXCLUDE]
                    hideProgressDialog();
                    // [END_EXCLUDE]
                }
            });
    // [END link_credential]
}
 
开发者ID:firebase,项目名称:quickstart-android,代码行数:40,代码来源:AnonymousAuthActivity.java

示例5: linkAccount

import com.google.firebase.auth.EmailAuthProvider; //导入方法依赖的package包/类
private void linkAccount() {
    // Make sure form is valid
    if (!validateLinkForm()) {
        return;
    }

    // Get email and password from form
    String email = mEmailField.getText().toString();
    String password = mPasswordField.getText().toString();

    // Create EmailAuthCredential with email and password
    AuthCredential credential = EmailAuthProvider.getCredential(email, password);

    // Link the anonymous user to the email credential
    showProgressDialog();
    // [START link_credential]
    mAuth.getCurrentUser().linkWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "linkWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Toast.makeText(AnonymousAuthActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }

                    // [START_EXCLUDE]
                    hideProgressDialog();
                    // [END_EXCLUDE]
                }
            });
    // [END link_credential]
}
 
开发者ID:GoogleCloudPlatform,项目名称:endpoints-samples,代码行数:38,代码来源:AnonymousAuthActivity.java

示例6: linkCredentials

import com.google.firebase.auth.EmailAuthProvider; //导入方法依赖的package包/类
@Override
public Observable<User> linkCredentials(Credentials credentials) {
    AuthCredential emailCredentials = EmailAuthProvider.getCredential(credentials.getEmail(), credentials.getPassword());
    return firebaseWrapper.linkAccount(emailCredentials)
            .map(authResult -> authResult.getUser())
            .map(firebaseUser -> UserAdapter.fromFirebaseUser(firebaseUser));
}
 
开发者ID:bmelnychuk,项目名称:outlay,代码行数:8,代码来源:FirebaseAuthService.java

示例7: getEmailAuthCredential

import com.google.firebase.auth.EmailAuthProvider; //导入方法依赖的package包/类
private static AuthCredential getEmailAuthCredential(final JSONObject credential) throws Exception {
    final String email = credential.getString("email");
    final String password = credential.getString("password");
    return EmailAuthProvider.getCredential(email, password);
}
 
开发者ID:jsayol,项目名称:cordova-plugin-firebase-sdk,代码行数:6,代码来源:AuthCredentials.java

示例8: busAction

import com.google.firebase.auth.EmailAuthProvider; //导入方法依赖的package包/类
@Subscribe(threadMode = ThreadMode.MAIN)
public void busAction(BusEvent busEvent) {
    //这里更新视图或者后台操作,从busAction获取传递参数.
    if (busEvent != null) {
        switch (busEvent.getFlag()) {
            case BUS_FLAG_CAMERA:
                onCameraClick(mView, true);
                break;
            case BUS_FLAG_ALBUM:
                onAlbumClick(mView, true);
                break;
            case BUS_FLAG_USERNAME:
                if (busEvent.getMessage() != null) {
                    mNickname.setText(busEvent.getMessage());
                    mUser.setNickname(busEvent.getMessage());
                    UserUtils.saveUserToCache(mActivity.getApplicationContext(), mUser);
                    updateProfile(busEvent.getMessage(), null);
                }
                break;
            case BUS_FLAG_EMAIL:
                if (busEvent.getMessage().contains("@")) {
                    AuthUtils.sendRPEmail(mActivity, mView, busEvent.getMessage());
                }
                break;
            case BUS_FLAG_DELETE_ACCOUNT:
                if (busEvent.getMessage() != null) {
                    final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
                    AuthCredential credential =
                            EmailAuthProvider.getCredential(user.getEmail(), busEvent.getMessage());
                    FDatabaseUtils.emptyNote(user.getUid());
                    FDatabaseUtils.emptyTrash(user.getUid());

                    user.reauthenticate(credential)
                        .addOnCompleteListener(task -> user.delete().addOnCompleteListener(task1 -> {
                            if (task1.isSuccessful()) {
                                if (BuildConfig.DEBUG) { Log.d(TAG, "busAction: User account deleted."); }
                                startActivity(new Intent(mActivity, LoginActivity.class));
                            }
                        }).addOnFailureListener(e -> {
                            if (BuildConfig.DEBUG) { Log.d(TAG, e.toString()); }
                        }));
                }
                break;
        }
    }
}
 
开发者ID:Art2Cat,项目名称:MoonlightNote,代码行数:47,代码来源:UserFragment.java


注:本文中的com.google.firebase.auth.EmailAuthProvider.getCredential方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。