for some reason, the data is not being added to the firebase database. maybe its because i set the database in test mode? i have no idea. this was working before, however today it stopped working.
private EditText EditTextFullName, EditTextAge, EditTextEmail, EditTextPassword;
private TextView registerUser;
private FirebaseAuth mAuth;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
mAuth = FirebaseAuth.getInstance();
Objects.requireNonNull(getSupportActionBar()).hide();
EditTextFullName = (EditText) findViewById(R.id.fullName);
EditTextAge = (EditText) findViewById(R.id.age);
EditTextEmail = (EditText) findViewById(R.id.email);
EditTextPassword = (EditText) findViewById(R.id.password);
registerUser= (Button) findViewById(R.id.registerUser);
registerUser.setOnClickListener(this);
}
#Override
public void onClick(View v) {
switch(v.getId()){
case R.id.registerUser:
registerUser();
break;
}
}
private void registerUser() {
String email = EditTextEmail.getText().toString().trim();
String age = EditTextAge.getText().toString().trim();
String fullname = EditTextFullName.getText().toString().trim();
String password = EditTextPassword.getText().toString().trim();
if(password.length() < 6) {
EditTextPassword.setError("Min password length should be 6 characters");
EditTextPassword.requestFocus();
return;
}
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if(task.isSuccessful()){
User user = new User(fullname, age, email);
FirebaseDatabase.getInstance().getReference("Users")
.child((FirebaseAuth.getInstance().getCurrentUser()).getUid())
.setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
if(task.isSuccessful())
{
Toast.makeText(Register.this, "User has been registered", Toast.LENGTH_LONG).show();
startActivity(new Intent(Register.this,Login.class));
} else
{
Toast.makeText(Register.this, "Failed to register", Toast.LENGTH_LONG).show();
}
};
});
}
}
});
}
}
Well it turns out that I completely flopped when writing my code. Turns out in my User class with my constructers, i had my strings there twice causing the database to not know what to use.
Related
I am new to android so there is some problem when i run the code to register or login with firebase authentication i can run the code but when i execute the signup function after pressing the register button it takes a lot time to register 1 account.
`
public class RegisterActivity extends AppCompatActivity implements View.OnClickListener {
private FirebaseAuth mAuth;
private Button btn_register;
private EditText et_name, et_age, et_email, et_password;
private ProgressBar ProgressBar;
private TextView name_project;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
mAuth = FirebaseAuth.getInstance();
name_project = (TextView) findViewById(R.id.name_project);
name_project.setOnClickListener(this);
btn_register = (Button) findViewById(R.id.btn_register);
btn_register.setOnClickListener(this);
et_name = (EditText) findViewById(R.id.et_name);
et_age = (EditText) findViewById(R.id.et_age);
et_email = (EditText) findViewById(R.id.et_email);
et_password = (EditText) findViewById(R.id.et_password);
ProgressBar = (ProgressBar) findViewById(R.id.progressBar);
}
#Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.name_project:
startActivity(new Intent(this, MainActivity.class));
break;
case R.id.btn_register:
registerUser();
break;
}
}
private void registerUser() {
String email = et_email.getText().toString().trim();
String password = et_password.getText().toString().trim();
String name = et_name.getText().toString().trim();
String age = et_age.getText().toString().trim();
if (name.isEmpty()) {
et_name.setError("Please enter your full name");
et_name.requestFocus();
return;
}
if (age.isEmpty()) {
et_age.setError("Please enter your age");
et_age.requestFocus();
return;
}
if (email.isEmpty()) {
et_email.setError("Please enter your email");
et_email.requestFocus();
return;
}
if (password.isEmpty()) {
et_password.setError("Please enter your password");
et_password.requestFocus();
return;
}
if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
et_email.setError("Please enter valid email");
et_email.requestFocus();
return;
}
if (password.length() < 6) {
et_password.setError("The length of password should be more than 6 letters");
et_password.requestFocus();
return;
}
ProgressBar.setVisibility(View.VISIBLE);
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Intent intent = new Intent(RegisterActivity.this, MainActivity.class);
startActivity(intent);
finish();
Toast.makeText(RegisterActivity.this, "Registered successfully", Toast.LENGTH_SHORT).show();
ProgressBar.setVisibility(View.GONE);
} else {
Toast.makeText(RegisterActivity.this, "Registered fail", Toast.LENGTH_SHORT).show();
ProgressBar.setVisibility(View.GONE);
}
}
});
}
}
enter image description here`
I have tried many methods but registration takes a long time.
Please make sure you have enabled the Email/Password provider in the Authentification tab on the Firebase console.
I am developing an app on android studio and need to redirect clients and personal trainers to two different activities based on their role. Personal Trainers need to be directed to PTNoticeboardActivity and clients to NoticeboardActivity. Any suggestion on how to do this, here is my login code:
public class MainActivity extends AppCompatActivity {
private FirebaseAuth firebaseAuth;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
firebaseAuth = FirebaseAuth.getInstance();
}
public void loginUser(View View){
String email = ((EditText) findViewById(R.id.editText_Log_email)).getText().toString();
String password = ((EditText) findViewById(R.id.editText_Log_password)).getText().toString();
if(TextUtils.isEmpty(email)){
Toast.makeText(this, "Please enter email", Toast.LENGTH_LONG).show();
return;
}
if (TextUtils.isEmpty(password)){
Toast.makeText(this, "Please Enter Password", Toast.LENGTH_LONG).show();
return;
}
firebaseAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener(MainActivity.this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if(task.isSuccessful()){
Toast.makeText(MainActivity.this, "Login Successful", Toast.LENGTH_LONG).show();
// startActivity(new Intent(getApplicationContext(), NoticeBoardActivity.class));
// finish();
} else {
Toast.makeText(MainActivity.this, "Login Unsuccessful", Toast.LENGTH_LONG).show();
}
}
});
}
}
Here is my register activity code below:
public class RegisterActivity extends AppCompatActivity {
EditText txt_fullname, txt_email, txt_mobilenumber, txt_repassword,
txt_password;
Button btn_register;
RadioButton radioJobClient, radioJobPT;
DatabaseReference databaseReference;
FirebaseDatabase firebaseDatabase;
String job ="";
FirebaseAuth firebaseAuth;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
txt_fullname = (EditText) findViewById(R.id.editText_fullname);
txt_email = (EditText) findViewById(R.id.editText_UserEmail);
txt_password = (EditText) findViewById(R.id.editText_Password);
txt_repassword = (EditText) findViewById(R.id.editText_rePassword);
txt_mobilenumber = (EditText) findViewById(R.id.mobilenumber);
btn_register = (Button) findViewById(R.id.button_reg);
radioJobClient = (RadioButton) findViewById(R.id.radio_Client);
radioJobPT = (RadioButton) findViewById(R.id.radio_PersonalTrainer);
databaseReference = FirebaseDatabase.getInstance().getReference("User");
// new code
firebaseAuth = FirebaseAuth.getInstance();
btn_register.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
final String fullname = txt_fullname.getText().toString();
final String email = txt_email.getText().toString();
final String mobilenumber = txt_mobilenumber.getText().toString();
final String password = txt_password.getText().toString();
final String rePassword = txt_repassword.getText().toString();
if (radioJobClient.isChecked()){
job = "Client";
}
if (radioJobPT.isChecked()){
job = "PT";
}
if (TextUtils.isEmpty(email)){
Toast.makeText(RegisterActivity.this, "Please enter Email", Toast.LENGTH_LONG).show();
}
if (TextUtils.isEmpty(fullname)){
Toast.makeText(RegisterActivity.this, "Please enter fullname", Toast.LENGTH_LONG).show();
}
if (TextUtils.isEmpty(password)){
Toast.makeText(RegisterActivity.this, "Please enter password", Toast.LENGTH_LONG).show();
}
firebaseAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(RegisterActivity.this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
User user = new User(
fullname,
email,
mobilenumber,
password,
job
);
FirebaseDatabase.getInstance().getReference("User")
.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
Toast.makeText(RegisterActivity.this, "Registration Complete", Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(),MainActivity.class));
}
});
} else {
Toast.makeText(RegisterActivity.this, "Registration Unsuccessful", Toast.LENGTH_LONG).show();
}
// ...
}
});
}
});
}
public void goLogin (View view){
startActivity(new Intent(RegisterActivity.this, MainActivity.class));
}
}
Database structure:
This is the most efficient way to do it:
When your user has created an account, create a child node in the firebase database as role with value as per the user. [could be client or personal trainer]
Then when your activity starts, fetch the value from the database like this:
First of all add a LOGIN BUTTON toyour login activity. When user presses that then only the login thing will take place.
Here is your modified MainActivity.java:
public class MainActivity extends AppCompatActivity {
private FirebaseAuth firebaseAuth;
String userRole;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
firebaseAuth = FirebaseAuth.getInstance();
btnLogin = findViewById(R.id.btn_login_resource);
btnLogin.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String email = ((EditText) findViewById(R.id.editText_Log_email)).getText().toString();
String password = ((EditText) findViewById(R.id.editText_Log_password)).getText().toString();
if(TextUtils.isEmpty(email)){
Toast.makeText(this, "Please enter email", Toast.LENGTH_LONG).show();
return;
}
else if (TextUtils.isEmpty(password)){
Toast.makeText(this, "Please Enter Password", Toast.LENGTH_LONG).show();
return;
}
else{
firebaseAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener(MainActivity.this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if(task.isSuccessful()){
Toast.makeText(MainActivity.this, "Login Successful", Toast.LENGTH_LONG).show();
jobRef = FirebaseDatabase.getInstance().getReference().child("User").child(pAuth.getCurrentUser().getUid()).child("job");
jobRef.addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(#NonNull DataSnapshot dataSnapshot) {
try {
userRole = dataSnapshot.getValue().toString();
if(userRole.equals("Client")){
startActivity(new Intent(MainActivity.this, NoticeboardActivity.class);
}
else {
startActivity(new Intent(MainActivity.this, PTNoticeboardActivity.class);
}
}catch (Throwable e){
Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_SHORT).show();
}
}
#Override
public void onCancelled(#NonNull DatabaseError databaseError) {
Toast.makeText(getApplicationContext(), databaseError.toString(), Toast.LENGTH_SHORT).show();
}
});
} else {
Toast.makeText(MainActivity.this, "Login Unsuccessful", Toast.LENGTH_LONG).show();
}
}
});
}
}
}
});
.
Now one thing to care about is that anyone can reverse-engineer this code and illegally can get access to the data. So make sure the data in each activity is hosted in Firebase and you have set the appropriate firebase rules. If you want me to elaborate please let me know in the comments down below.
I am saving user information to a realtime database on a android studio app. When the user goes to register they select weather they are a PT or client by using radio buttons. As shown in my database all the user information is being saved under the user child node on firebase. Is there a way I can create subheadings called PT and Clients underneath user in the realtime database by using the radio buttons. Sign up code is:
public class RegisterActivity extends AppCompatActivity {
EditText txt_fullname, txt_email, txt_mobilenumber, txt_repassword, txt_password;
Button btn_register;
RadioButton radioJobClient, radioJobPT;
DatabaseReference databaseReference;
FirebaseDatabase firebaseDatabase;
String job ="";
FirebaseAuth firebaseAuth;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
txt_fullname = (EditText) findViewById(R.id.editText_fullname);
txt_email = (EditText) findViewById(R.id.editText_UserEmail);
txt_password = (EditText) findViewById(R.id.editText_Password);
txt_repassword = (EditText) findViewById(R.id.editText_rePassword);
txt_mobilenumber = (EditText) findViewById(R.id.mobilenumber);
btn_register = (Button) findViewById(R.id.button_reg);
radioJobClient = (RadioButton) findViewById(R.id.radio_Client);
radioJobPT = (RadioButton) findViewById(R.id.radio_PersonalTrainer);
databaseReference = FirebaseDatabase.getInstance().getReference("User");
// new code
firebaseAuth = FirebaseAuth.getInstance();
btn_register.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
final String fullname = txt_fullname.getText().toString();
final String email = txt_email.getText().toString();
final String mobilenumber = txt_mobilenumber.getText().toString();
final String password = txt_password.getText().toString();
final String rePassword = txt_repassword.getText().toString();
if (radioJobClient.isChecked()){
job = "Client";
}
if (radioJobPT.isChecked()){
job = "PT";
}
if (TextUtils.isEmpty(email)){
Toast.makeText(RegisterActivity.this, "Please enter Email", Toast.LENGTH_LONG).show();
}
if (TextUtils.isEmpty(fullname)){
Toast.makeText(RegisterActivity.this, "Please enter fullname", Toast.LENGTH_LONG).show();
}
if (TextUtils.isEmpty(password)){
Toast.makeText(RegisterActivity.this, "Please enter password", Toast.LENGTH_LONG).show();
}
firebaseAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(RegisterActivity.this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
User user = new User(
fullname,
email,
mobilenumber,
password,
job
);
FirebaseDatabase.getInstance().getReference("User")
.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
Toast.makeText(RegisterActivity.this, "Registration Complete", Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(),MainActivity.class));
}
});
} else {
Toast.makeText(RegisterActivity.this, "Registration Unsuccessful", Toast.LENGTH_LONG).show();
}
// ...
}
});
}
});
}
if (radioJobClient.isChecked()){
job = "Client";
FirebaseDatabase.getInstance().getReference("User").child(job).child(FirebaseAuth.getInstance().getCurrentUser().getUid()).setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
Toast.makeText(RegisterActivity.this, "Registration Complete", Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(),MainActivity.class));
}
});
}
if (radioJobPT.isChecked()){
job = "PT";
FirebaseDatabase.getInstance().getReference("User").child(job).child(FirebaseAuth.getInstance().getCurrentUser().getUid()).setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
Toast.makeText(RegisterActivity.this, "Registration Complete", Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(),MainActivity.class));
User register as student or tutor during registration which saved in firebase database but when login cannot identify the user position which saved in the firebase database so what should I do? Please anyone can give suggestion or advice me how to do this.
The database is save the uid from email authentication as the node under the root then rest details is the children of the uid.
The code like this
private FirebaseAuth auth;
private EditText un, pw;
private String getun, getpw, uid;
private Button bl;
private FirebaseDatabase db;
private DatabaseReference ref;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
auth = FirebaseAuth.getInstance();
db = FirebaseDatabase.getInstance();
ref = db.getReference();
uid = auth.getCurrentUser().getUid();
ref = db.getReference("users").child(uid);
un = (EditText) findViewById(R.id.Lun);
pw = (EditText) findViewById(R.id.Lpw);
bl = (Button) findViewById(R.id.Lbt);
final TextView rl = (TextView) findViewById(R.id.Lreg);
//login
bl.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
getun = un.getText().toString().trim();
getpw = pw.getText().toString().trim();
loginaction(getun, getpw);
}
});
//open register page
rl.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent ri = new Intent(Login.this,Register.class);
Login.this.startActivity(ri);
}
});
}
private void loginaction(String a, String b){
auth.signInWithEmailAndPassword(a, b).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
Log.d("Login", "Login Success" + task.isSuccessful());
if (!task.isSuccessful()) {
Log.w("Login", "Login Failed", task.getException());
Toast.makeText(Login.this, "Login Failed. Please try again", Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(Login.this, "Login Success", Toast.LENGTH_SHORT).show();
ref.orderByChild("position").addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
String ps = dataSnapshot.getValue().toString();
if(ps.equalsIgnoreCase("student")){
Intent i = new Intent(Login.this, StudentHomePage.class);
startActivity(i);
}else if (ps.equalsIgnoreCase("tutor")){
Intent i = new Intent(Login.this, TutorHomePage.class);
startActivity(i);
}else{
Toast.makeText(Login.this,
"Wrong input. Please check again the email and password.", Toast.LENGTH_SHORT).show();
return;
}
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
// ...
}
});
}
Create two child nodes from users. One for students and one for tutors.(Give both child values a value of true, otherwise firebase doesn't save the children.)
Have two registration buttons ..one for students and one for tutors. Registration for Tutor code.....
mRegistration.setOnClickListener(new
View.OnClickListener() {
#Override
public void onClick(View v) {
final String email = mEmail.getText().toString();
final String password = mPassword.getText().toString();
mAuth.createUserWithEmailAndPassword(email,password).addOnCompleteListener(DriverLoginActivity.this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (!task.isSuccessful()){
Toast.makeText(TutorsLoginActivity.this, "Sign in error", Toast.LENGTH_SHORT).show();
}else{
String user_id= mAuth.getCurrentUser().getUid();
DatabaseReference current_user_db= FirebaseDatabase.getInstance().getReference().child("Users").child("Tutors").child(user_id);
current_user_db.setValue(true);
}
}
});
}
});
Do the same for the students. Just change the .child("Tutors") to .child("Students") This will give you UIDs for the two different groups. And you can do the same when logging in. I think this is a better way to proceed.
I created a register activity with Firebase Authentication, but when I ran the application and clicked on the sign up button, nothing happened. Only the progress dialog, just rotating and it didn't even signup.
Here is my code:
public class RegisterActivity extends AppCompatActivity {
private EditText mNameField;
private EditText mEmailField;
private EditText mPasswordField;
private Button mRegisterBtn;
private FirebaseAuth mAuth;
private DatabaseReference mDatabase;
private ProgressDialog mProgress;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
mAuth = FirebaseAuth.getInstance();
mDatabase = FirebaseDatabase.getInstance().getReference().child("users");
mProgress = new ProgressDialog(this);
mNameField = (EditText) findViewById(R.id.nameFied);
mEmailField = (EditText) findViewById(R.id.emailField);
mPasswordField = (EditText) findViewById(R.id.passwordField);
mRegisterBtn = (Button) findViewById(R.id.registerBtn);
mRegisterBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startRegister();
}
});
}
private void startRegister() {
final String name = mNameField.getText().toString().trim();
String email = mEmailField.getText().toString().trim();
String password = mPasswordField.getText().toString().trim();
if(!TextUtils.isEmpty(name) && !TextUtils.isEmpty(email) && !TextUtils.isEmpty(password)){
mProgress.setMessage("Signing up...please wait");
mProgress.show();
mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()){
String user_id = mAuth.getCurrentUser().getUid();
DatabaseReference current_user_db = mDatabase.child(user_id);
current_user_db.child("name").setValue(name);
current_user_db.child("image").setValue("default");
mProgress.dismiss();
Intent mainIntent = new Intent(RegisterActivity.this, MainActivity.class);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(mainIntent);
}
}
});
}
if (TextUtils.isEmpty(name) && TextUtils.isEmpty(email) && TextUtils.isEmpty(password)){
Toast.makeText(RegisterActivity.this, "do not leave any field empty", Toast.LENGTH_LONG).show();
}
}
}
I don't know what I did wrong.
Here are my gradle dependencies:
compile 'com.google.firebase:firebase-database:9.2.0'
compile 'com.google.firebase:firebase-auth:9.2.0'
try to add a OnFailureListener to see what exception or error you are getting.
mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()){
String user_id = mAuth.getCurrentUser().getUid();
DatabaseReference current_user_db = mDatabase.child(user_id);
current_user_db.child("name").setValue(name);
current_user_db.child("image").setValue("default");
mProgress.dismiss();
Intent mainIntent = new Intent(RegisterActivity.this, MainActivity.class);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(mainIntent);
}
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Log.i("Firebase Exception -> ",e.getMessage());
}});
You are creating user with
createUserWithEmailAndPassword(email, password)
but you never sign-in. You also need to sign in after creating user with
signInWithEmailAndPassword(email, password)
and in that add data to your database.
And I would suggest to update your repository and decencies also.