Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions _hunter_prompt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
You are an elite open-source bounty hunter and senior software engineer.
Your task is to fix GitHub Issue #5 in the repository allknowledge34/UpdateApp.

Issue Title: $0.4 Bounty : Login fails with "Invalid Email" after successful signup and OTP verification
Issue Body:
---
### Description
After completing the signup process successfully, login does not work with the same email and password.
The app shows an **"Invalid Email"** error during login.

### Signup Flow
1. User signs up using:
- Name
- Email
- Phone number
- Password
2. After signup, the app redirects to **phone number OTP verification**
3. OTP is entered correctly and verified
4. Account is created successfully

### Issue
After logging out, when trying to log in using the **same email and password** used during signup,
the login fails and shows **"Invalid Email"** error.

### Steps to Reproduce
1. Open the app
2. Go to Signup screen
3. Enter name, email, phone number, and password
4. Verify phone number using OTP
5. Logout after successful signup
6. Go to Login screen
7. Enter the same email and password
8. Login fails with "Invalid Email" error

### Expected Behavior
User should be able to log in successfully using the same email and password after signup.

### Actual Behavior
Login fails with "Invalid Email" error even though the account was created successfully.

### Platform
- Java (Android)
- Email & Phone OTP Authentication

### Additional Information
- OTP verification works correctly
- Signup flow completes without any error
- Issue happens only during login after signup

---

Instructions:
1. You are currently in the repository directory.
2. Read the codebase to understand the context of the bug.
3. Modify the code to fix the bug.
4. Ensure the tests pass.
5. Once you are 100% confident the fix is correct, run "git diff" to review your changes, but DO NOT commit or push yet. Just leave the code modified in the workspace.
6. Reply with a summary of what you fixed and the root cause.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Remove AI agent prompt artifact from the repository.

_hunter_prompt.txt is an internal task file generated for an automated bounty-hunter agent. It has no runtime role, exposes internal AI-assisted development tooling, and should be deleted before merging. Add it (and similar prompt files) to .gitignore to prevent accidental future commits.

🧰 Tools
🪛 LanguageTool

[grammar] ~29-~29: Ensure spelling is correct
Context: ...assword 4. Verify phone number using OTP 5. Logout after successful signup 6. Go to Login ...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@_hunter_prompt.txt` around lines 1 - 58, Remove the internal AI prompt file
_hunter_prompt.txt from the repository and add a rule to .gitignore to prevent
future commits of similar prompt artifacts; specifically delete the file entry
(remove or stop tracking _hunter_prompt.txt and any other *_prompt.txt files)
and add a line like "*_prompt.txt" or "_hunter_prompt.txt" to .gitignore, then
check for other prompt artifacts and stop-tracking them if present (update index
if needed so the ignored files are no longer staged).

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.google.firebase.firestore.FirebaseFirestore;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

public class LoginActivity extends AppCompatActivity {
Expand Down Expand Up @@ -69,72 +70,10 @@ protected void onCreate(Bundle savedInstanceState) {
progressDialog.setTitle(getString(R.string.logging_in));
progressDialog.setMessage(getString(R.string.please_wait));

binding.emailBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

String email = binding.edtEmail.getText().toString();
String password = binding.edtPassword.getText().toString();

if (email.isEmpty()) {
binding.edtEmail.setError(getString(R.string.enter_valid_email));
} else if (password.isEmpty()) {
binding.edtPassword.setError(getString(R.string.enter_strong_password));
} else {

progressDialog.show();
auth.signInWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {

if (task.isSuccessful()) {
progressDialog.dismiss();
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
finish();
} else {
progressDialog.dismiss();
Toast.makeText(LoginActivity.this, task.getException().getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
}
});

binding.emailBtn.setOnClickListener(v -> performEmailLogin());

binding.btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

String email = binding.edtEmail.getText().toString();
String password = binding.edtPassword.getText().toString();

if (email.isEmpty()) {
binding.edtEmail.setError(getString(R.string.enter_valid_email));
} else if (password.isEmpty()) {
binding.edtPassword.setError(getString(R.string.enter_strong_password));
} else {

progressDialog.show();
auth.signInWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {

if (task.isSuccessful()) {
progressDialog.dismiss();
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
finish();
} else {
progressDialog.dismiss();
Toast.makeText(LoginActivity.this, task.getException().getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
}
});
binding.btnLogin.setOnClickListener(v -> performEmailLogin());

binding.forgotPassword.setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -160,6 +99,32 @@ public void onClick(View v) {
googleBtn.setOnClickListener(v -> signInWithGoogle());
}

private void performEmailLogin() {
String email = binding.edtEmail.getText().toString().trim().toLowerCase(Locale.ROOT);
String password = binding.edtPassword.getText().toString();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Password not trimmed — inconsistent with signup normalization.

SignUpActivity.doValidation() trims the password before createUserWithEmailAndPassword, and the PR objectives explicitly include .trim() on the password in both flows. If a user's password had leading/trailing whitespace during signup it is stripped and stored trimmed; the untrimmed login input won't match, reproducing a variant of the same authentication mismatch bug this PR is fixing.

🐛 Proposed fix
-        String password = binding.edtPassword.getText().toString();
+        String password = binding.edtPassword.getText().toString().trim();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String password = binding.edtPassword.getText().toString();
String password = binding.edtPassword.getText().toString().trim();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/example/updateapp/views/activites/LoginActivity.java`
at line 104, LoginActivity currently reads the password without trimming (String
password = binding.edtPassword.getText().toString()) causing login to fail when
signup trimmed stored passwords; update the LoginActivity login flow to trim the
password input (mirror SignUpActivity.doValidation behavior) before calling the
authentication method (createUserWithEmailAndPassword / signIn call) so both
signup and login normalize whitespace consistently, referencing
binding.edtPassword and the login method in LoginActivity.


if (email.isEmpty()) {
binding.edtEmail.setError(getString(R.string.enter_valid_email));
} else if (password.isEmpty()) {
binding.edtPassword.setError(getString(R.string.enter_strong_password));
} else {
progressDialog.show();
auth.signInWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
progressDialog.dismiss();
if (task.isSuccessful()) {
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
finish();
} else {
Toast.makeText(LoginActivity.this, task.getException().getLocalizedMessage(), Toast.LENGTH_SHORT).show();
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}
}
});
}
}

void signInWithGoogle() {
Intent intent = gsc.getSignInIntent();
startActivityForResult(intent, 1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.firebase.auth.PhoneAuthOptions;
import com.google.firebase.auth.PhoneAuthProvider;

import java.util.Locale;
import java.util.concurrent.TimeUnit;

public class SignUpActivity extends AppCompatActivity {
Expand Down Expand Up @@ -69,9 +70,9 @@ protected void onCreate(Bundle savedInstanceState) {

private void doValidation() {

String name = binding.edtName.getText().toString();
String email = binding.edtEmail.getText().toString();
String number = binding.edtMobile.getText().toString();
String name = binding.edtName.getText().toString().trim();
String email = binding.edtEmail.getText().toString().trim().toLowerCase(Locale.ROOT);
String number = binding.edtMobile.getText().toString().trim();
String password = binding.edtPassword.getText().toString();

if (name.isEmpty()) { binding.edtName.setError(getString(R.string.enter_good_name)); return; }
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
android:textSize="16sp"
android:textColor="#A2A4b5"
android:ems="10"
android:inputType="textPersonName"
android:inputType="textEmailAddress"
android:background="@drawable/background_edit" />

<TextView
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_sign_up.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
android:textSize="16sp"
android:textColor="#A2A4b5"
android:ems="10"
android:inputType="textPersonName"
android:inputType="textEmailAddress"
android:background="@drawable/background_edit" />

<TextView
Expand All @@ -123,7 +123,7 @@
android:textSize="16sp"
android:textColor="#A2A4b5"
android:ems="10"
android:inputType="textPhonetic"
android:inputType="phone"
android:background="@drawable/background_edit" />

<TextView
Expand Down