Answer the question
In order to leave comments, you need to log in
Why is the user added to the database even before he clicked on the link in the mail?
When registering, a message is sent in which there is a link, after clicking on which the user should be added to the database, but the user is added without clicking on the link, what could be the problem?
public class RegistrationActivity extends AppCompatActivity implements View.OnClickListener{
private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthListener;
private EditText ETemail;
private EditText ETpassword;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registration);
mAuth = FirebaseAuth.getInstance();
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
} else {
// User is signed out
}
}
};
ETemail = (EditText) findViewById(R.id.et_email);
ETpassword = (EditText) findViewById(R.id.et_password);
findViewById(R.id.btn_registration).setOnClickListener(this);
}
@Override
public void onClick(View view) {
if (view.getId() == R.id.btn_registration) {
if (ETemail.getText().length() != 0 && ETpassword.getText().length() != 0){
registration(ETemail.getText().toString(), ETpassword.getText().toString());
} else {
Toast.makeText(RegistrationActivity.this, "Заполните все поля", Toast.LENGTH_SHORT).show();
}
}
}
public void registration(String email, String password) {
mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Intent intent = new Intent(RegistrationActivity.this, LoginActivity.class);
startActivity(intent);
//Отправка подтверждения на почту
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
user.sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d("TAG", "Email успешно отправлен");
}
}
});
/*Toast.makeText(RegistrationActivity.this, "Регистрация успешна", Toast.LENGTH_SHORT).show();*/
} else
Toast.makeText(RegistrationActivity.this, "Регистрация провалена", Toast.LENGTH_SHORT).show();
}
});
}
public void PLogin(View view) {
Intent intent = new Intent(RegistrationActivity.this, LoginActivity.class);
startActivity(intent);
}
}
Answer the question
In order to leave comments, you need to log in
createUserWithEmailAndPassword()- what did you expect from this method? And in my opinion it is logical that in order to verify someone, he must exist, if there is no one in the database, then there is no one to verify (:
false
, then send the user to hell, if true, then the user has verified
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question