How can I put Firebase database code into my Frebase auth code? [closed]
up vote
2
down vote
favorite
How can I put Firabase Database code into my Frebase auth code? so that the data will only save into the database if there are no errors or onComplete.
Firebase database code:
if (!nameStr.isEmpty())
String ID = GDatabase.push().getKey();
Accounts accounts = new Accounts(ID, nameStr, genderStr, emailStr, passwordStr);
GDatabase.child(ID).setValue(accounts);
else
Toast.makeText(MainActivity.this, "Unable to save data into the database", Toast.LENGTH_SHORT).show();
Firebase auth code:
firebaseAuth.createUserWithEmailAndPassword(emailStr, passwordStr)
.addOnCompleteListener(new OnCompleteListener<AuthResult>()
@Override
public void onComplete(@NonNull Task<AuthResult> task)
progressBar.setVisibility(View.GONE);
if (task.isSuccessful())
firebaseAuth.getCurrentUser().sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener<Void>()
@Override
public void onComplete(@NonNull Task<Void> task)
if (task.isSuccessful())
Toast.makeText(MainActivity.this, "Registered successfully. Please check your email for verification",
Toast.LENGTH_LONG).show();
email.setText("");
password.setText("");
else
Toast.makeText(MainActivity.this, task.getException().getMessage(),
Toast.LENGTH_LONG).show();
);
);
All of my code from that class:
public class MainActivity extends AppCompatActivity
boolean connected = false;
private String blockCharacterSet = "~#^
java android firebase firebase-realtime-database firebase-authentication
closed as unclear what you're asking by Frank van Puffelen, Doug Stevenson, Nicholas K, Martin Zeitler, Alex Mamo Nov 12 at 19:37
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
2
down vote
favorite
How can I put Firabase Database code into my Frebase auth code? so that the data will only save into the database if there are no errors or onComplete.
Firebase database code:
if (!nameStr.isEmpty())
String ID = GDatabase.push().getKey();
Accounts accounts = new Accounts(ID, nameStr, genderStr, emailStr, passwordStr);
GDatabase.child(ID).setValue(accounts);
else
Toast.makeText(MainActivity.this, "Unable to save data into the database", Toast.LENGTH_SHORT).show();
Firebase auth code:
firebaseAuth.createUserWithEmailAndPassword(emailStr, passwordStr)
.addOnCompleteListener(new OnCompleteListener<AuthResult>()
@Override
public void onComplete(@NonNull Task<AuthResult> task)
progressBar.setVisibility(View.GONE);
if (task.isSuccessful())
firebaseAuth.getCurrentUser().sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener<Void>()
@Override
public void onComplete(@NonNull Task<Void> task)
if (task.isSuccessful())
Toast.makeText(MainActivity.this, "Registered successfully. Please check your email for verification",
Toast.LENGTH_LONG).show();
email.setText("");
password.setText("");
else
Toast.makeText(MainActivity.this, task.getException().getMessage(),
Toast.LENGTH_LONG).show();
);
);
All of my code from that class:
public class MainActivity extends AppCompatActivity
boolean connected = false;
private String blockCharacterSet = "~#^
java android firebase firebase-realtime-database firebase-authentication
closed as unclear what you're asking by Frank van Puffelen, Doug Stevenson, Nicholas K, Martin Zeitler, Alex Mamo Nov 12 at 19:37
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
What are you stuck on in particular?
– halfer
Nov 10 at 21:21
Umm. Everytime the user sign up an account the app always adds data to the database even if there is an error if the firebase auth failed. So I want the data to be added to the database only If the the authentication is a success.
– Patrick Mangubat
Nov 11 at 2:40
Sotask.isSuccessful()
istrue
even if the Firebase auth failed? (I am not familiar with Java/Android - just trying to narrow the question down, as you have 4 close votes. I assume readers think this is too broad).
– halfer
Nov 11 at 10:14
So am I.. I just started to code recently. I will try to revise my code. There is an 'else' that has the 'task.getException()' to catch if it is false. But the problem is. the data will save into the database, but wont send an email authentication. Thanks for the help. I think i just realize the solution. But thank you So much!
– Patrick Mangubat
Nov 11 at 12:27
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
How can I put Firabase Database code into my Frebase auth code? so that the data will only save into the database if there are no errors or onComplete.
Firebase database code:
if (!nameStr.isEmpty())
String ID = GDatabase.push().getKey();
Accounts accounts = new Accounts(ID, nameStr, genderStr, emailStr, passwordStr);
GDatabase.child(ID).setValue(accounts);
else
Toast.makeText(MainActivity.this, "Unable to save data into the database", Toast.LENGTH_SHORT).show();
Firebase auth code:
firebaseAuth.createUserWithEmailAndPassword(emailStr, passwordStr)
.addOnCompleteListener(new OnCompleteListener<AuthResult>()
@Override
public void onComplete(@NonNull Task<AuthResult> task)
progressBar.setVisibility(View.GONE);
if (task.isSuccessful())
firebaseAuth.getCurrentUser().sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener<Void>()
@Override
public void onComplete(@NonNull Task<Void> task)
if (task.isSuccessful())
Toast.makeText(MainActivity.this, "Registered successfully. Please check your email for verification",
Toast.LENGTH_LONG).show();
email.setText("");
password.setText("");
else
Toast.makeText(MainActivity.this, task.getException().getMessage(),
Toast.LENGTH_LONG).show();
);
);
All of my code from that class:
public class MainActivity extends AppCompatActivity
boolean connected = false;
private String blockCharacterSet = "~#^
java android firebase firebase-realtime-database firebase-authentication
How can I put Firabase Database code into my Frebase auth code? so that the data will only save into the database if there are no errors or onComplete.
Firebase database code:
if (!nameStr.isEmpty())
String ID = GDatabase.push().getKey();
Accounts accounts = new Accounts(ID, nameStr, genderStr, emailStr, passwordStr);
GDatabase.child(ID).setValue(accounts);
else
Toast.makeText(MainActivity.this, "Unable to save data into the database", Toast.LENGTH_SHORT).show();
Firebase auth code:
firebaseAuth.createUserWithEmailAndPassword(emailStr, passwordStr)
.addOnCompleteListener(new OnCompleteListener<AuthResult>()
@Override
public void onComplete(@NonNull Task<AuthResult> task)
progressBar.setVisibility(View.GONE);
if (task.isSuccessful())
firebaseAuth.getCurrentUser().sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener<Void>()
@Override
public void onComplete(@NonNull Task<Void> task)
if (task.isSuccessful())
Toast.makeText(MainActivity.this, "Registered successfully. Please check your email for verification",
Toast.LENGTH_LONG).show();
email.setText("");
password.setText("");
else
Toast.makeText(MainActivity.this, task.getException().getMessage(),
Toast.LENGTH_LONG).show();
);
);
All of my code from that class:
public class MainActivity extends AppCompatActivity
boolean connected = false;
private String blockCharacterSet = "~#^
java android firebase firebase-realtime-database firebase-authentication
java android firebase firebase-realtime-database firebase-authentication
edited Nov 10 at 21:20
halfer
14.2k758106
14.2k758106
asked Nov 10 at 14:12
Patrick Mangubat
245
245
closed as unclear what you're asking by Frank van Puffelen, Doug Stevenson, Nicholas K, Martin Zeitler, Alex Mamo Nov 12 at 19:37
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Frank van Puffelen, Doug Stevenson, Nicholas K, Martin Zeitler, Alex Mamo Nov 12 at 19:37
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
What are you stuck on in particular?
– halfer
Nov 10 at 21:21
Umm. Everytime the user sign up an account the app always adds data to the database even if there is an error if the firebase auth failed. So I want the data to be added to the database only If the the authentication is a success.
– Patrick Mangubat
Nov 11 at 2:40
Sotask.isSuccessful()
istrue
even if the Firebase auth failed? (I am not familiar with Java/Android - just trying to narrow the question down, as you have 4 close votes. I assume readers think this is too broad).
– halfer
Nov 11 at 10:14
So am I.. I just started to code recently. I will try to revise my code. There is an 'else' that has the 'task.getException()' to catch if it is false. But the problem is. the data will save into the database, but wont send an email authentication. Thanks for the help. I think i just realize the solution. But thank you So much!
– Patrick Mangubat
Nov 11 at 12:27
add a comment |
What are you stuck on in particular?
– halfer
Nov 10 at 21:21
Umm. Everytime the user sign up an account the app always adds data to the database even if there is an error if the firebase auth failed. So I want the data to be added to the database only If the the authentication is a success.
– Patrick Mangubat
Nov 11 at 2:40
Sotask.isSuccessful()
istrue
even if the Firebase auth failed? (I am not familiar with Java/Android - just trying to narrow the question down, as you have 4 close votes. I assume readers think this is too broad).
– halfer
Nov 11 at 10:14
So am I.. I just started to code recently. I will try to revise my code. There is an 'else' that has the 'task.getException()' to catch if it is false. But the problem is. the data will save into the database, but wont send an email authentication. Thanks for the help. I think i just realize the solution. But thank you So much!
– Patrick Mangubat
Nov 11 at 12:27
What are you stuck on in particular?
– halfer
Nov 10 at 21:21
What are you stuck on in particular?
– halfer
Nov 10 at 21:21
Umm. Everytime the user sign up an account the app always adds data to the database even if there is an error if the firebase auth failed. So I want the data to be added to the database only If the the authentication is a success.
– Patrick Mangubat
Nov 11 at 2:40
Umm. Everytime the user sign up an account the app always adds data to the database even if there is an error if the firebase auth failed. So I want the data to be added to the database only If the the authentication is a success.
– Patrick Mangubat
Nov 11 at 2:40
So
task.isSuccessful()
is true
even if the Firebase auth failed? (I am not familiar with Java/Android - just trying to narrow the question down, as you have 4 close votes. I assume readers think this is too broad).– halfer
Nov 11 at 10:14
So
task.isSuccessful()
is true
even if the Firebase auth failed? (I am not familiar with Java/Android - just trying to narrow the question down, as you have 4 close votes. I assume readers think this is too broad).– halfer
Nov 11 at 10:14
So am I.. I just started to code recently. I will try to revise my code. There is an 'else' that has the 'task.getException()' to catch if it is false. But the problem is. the data will save into the database, but wont send an email authentication. Thanks for the help. I think i just realize the solution. But thank you So much!
– Patrick Mangubat
Nov 11 at 12:27
So am I.. I just started to code recently. I will try to revise my code. There is an 'else' that has the 'task.getException()' to catch if it is false. But the problem is. the data will save into the database, but wont send an email authentication. Thanks for the help. I think i just realize the solution. But thank you So much!
– Patrick Mangubat
Nov 11 at 12:27
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
What are you stuck on in particular?
– halfer
Nov 10 at 21:21
Umm. Everytime the user sign up an account the app always adds data to the database even if there is an error if the firebase auth failed. So I want the data to be added to the database only If the the authentication is a success.
– Patrick Mangubat
Nov 11 at 2:40
So
task.isSuccessful()
istrue
even if the Firebase auth failed? (I am not familiar with Java/Android - just trying to narrow the question down, as you have 4 close votes. I assume readers think this is too broad).– halfer
Nov 11 at 10:14
So am I.. I just started to code recently. I will try to revise my code. There is an 'else' that has the 'task.getException()' to catch if it is false. But the problem is. the data will save into the database, but wont send an email authentication. Thanks for the help. I think i just realize the solution. But thank you So much!
– Patrick Mangubat
Nov 11 at 12:27