gpt4 book ai didi

java - “此操作很敏感,需要最近的身份验证。”编辑用户密码和电子邮件Android时出错-Java

转载 作者:行者123 更新时间:2023-12-02 02:11:39 25 4
gpt4 key购买 nike

尝试从auth更改用户电子邮件和密码时收到此错误。
错误:http://prntscr.com/on0qg7(Imgur网站在我们的国家被禁止,所以我无法使用。)

该代码有时可行,有时会给出错误。不稳定

预先感谢您的帮助。

编辑方法代码:

public void editAlert() {
LayoutInflater layoutInflater = LayoutInflater.from(ProfilePage.this);

View design = layoutInflater.inflate(R.layout.edit_profile, null);
final FirebaseUser userAuth = FirebaseAuth.getInstance().getCurrentUser();

final EditText editTextUserName = design.findViewById(R.id.username_editTextProfileEdit);

final EditText editTextRealName = design.findViewById(R.id.realName_editTextProfileEdit);

final EditText editTextSurname = design.findViewById(R.id.surname_editTextProfileEdit);

final EditText editTextEmail = design.findViewById(R.id.email_editTextProfileEdit);

final EditText editTextPassword = design.findViewById(R.id.password_editTextProfileEdit);

AlertDialog.Builder alertDialoga = new AlertDialog.Builder(ProfilePage.this);
alertDialoga.setTitle("Edit Profile");
alertDialoga.setView(design);
alertDialoga.setPositiveButton("Finish", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
String username = editTextUserName.getText().toString().trim();
String realName = editTextRealName.getText().toString().trim();
String surname = editTextSurname.getText().toString().trim();
final String email = editTextEmail.getText().toString().trim();
final String password = editTextPassword.getText().toString().trim();
String admin = "false";
String url = "test_url";

String key = FirebaseAuth.getInstance().getCurrentUser().getUid();

Users user = new Users(key,username,realName,surname,email,password,url,admin);

HashMap<String,Object> data = new HashMap<>();

data.put("user_email", email);
data.put("user_name", realName);
data.put("user_password", password);
data.put("user_surname", surname);
data.put("user_username", username);

myRef.child(key).updateChildren(data);

// E Mail Update
userAuth.updateEmail(email).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(Task<Void> task) {
Toast.makeText(ProfilePage.this, "Mail değiştirildi", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Toast.makeText(ProfilePage.this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
});

// Password Update
userAuth.updatePassword(password).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(Task<Void> task) {
Toast.makeText(ProfilePage.this, "Şifre değiştirildi", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Toast.makeText(ProfilePage.this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}
});
}
});

alertDialoga.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {

}
});

alertDialoga.show();
}


从上面的代码部分,auth的替换代码为:

我的电子邮件和密码更改部分:

 // E Mail Update
userAuth.updateEmail(email).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(Task<Void> task) {
Toast.makeText(ProfilePage.this, "Mail değiştirildi", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Toast.makeText(ProfilePage.this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
});

// Password Update
userAuth.updatePassword(password).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(Task<Void> task) {
Toast.makeText(ProfilePage.this, "Şifre değiştirildi", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Toast.makeText(ProfilePage.this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}
});

最佳答案

如错误所言,用户需要最近登录才能执行此操作。要删除此用户,您必须重新验证该用户。有关如何执行此操作的更多信息,请参见here

关于java - “此操作很敏感,需要最近的身份验证。”编辑用户密码和电子邮件Android时出错-Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57325759/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com