Skip to content

Adding hard coded accounts#28

Open
Klvvr1 wants to merge 5 commits intomainfrom
Adding_HardCoded_Accounts
Open

Adding hard coded accounts#28
Klvvr1 wants to merge 5 commits intomainfrom
Adding_HardCoded_Accounts

Conversation

@Klvvr1
Copy link
Copy Markdown
Owner

@Klvvr1 Klvvr1 commented Apr 27, 2026

Add hardcoded test account buttons to the login screen for quick access and faster testing; auto-fill credentials and log in on click, restricted to development mode only.

Summary by CodeRabbit

  • Chores

    • Expanded seed data to create multiple predefined user accounts with distinct roles and updated test credentials.
    • Added debug-only quick-access login chips for faster role-based sign-in during development.
  • Bug Fixes

    • Improved login flow stability by preventing duplicate submissions and ensuring progress state is reliably reset after validation or async completion.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

Warning

Rate limit exceeded

@Klvvr1 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 42 minutes and 27 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b8297d10-c629-4e57-8b39-dc58edc3b0c5

📥 Commits

Reviewing files that changed from the base of the PR and between e319b33 and 7ac6dd8.

📒 Files selected for processing (2)
  • brightcleanproject/lib/features/auth/presentation/login_screen.dart
  • brightcleanproject/pubspec.yaml
📝 Walkthrough

Walkthrough

Adds seed data inserting four predefined users (Admin, Manager, Customer, Driver) with password changed to Password123, and introduces a debug-only quick-login UI on the login screen that fills credentials and triggers the existing login flow.

Changes

Cohort / File(s) Summary
Seed Data Initialization
brightcleanproject/lib/core/database/database_helper.dart
Replaces single hard-coded seed user with a testUsers list of four users (Admin, Manager, Customer, Driver); updates password to Password123 and inserts users iteratively via a loop.
Debug Quick-Login UI
brightcleanproject/lib/features/auth/presentation/login_screen.dart
Adds kDebugMode-gated ActionChips for each role that populate phone/password controllers and call _handleLogin() after a short delay; introduces _loginInProgress gating with proper finally-reset and null-safe validation.

Sequence Diagram(s)

sequenceDiagram
    participant DevUI as LoginScreen (Debug UI)
    participant Auth as Auth Handler / Bloc
    participant DB as DatabaseHelper
    participant Nav as Navigator

    DevUI->>Auth: _handleLogin(phone, password)
    Auth->>DB: query / authenticate user
    DB-->>Auth: user record / auth result
    Auth-->>Nav: on success -> navigate to home
    Auth-->>DevUI: on failure -> show error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Poem

🐰 Four whiskers, four roles, a debug-friendly cheer,
Chips that fill forms and seed users appear,
From Admin to Driver, quick tests take flight,
A little rabbit hops—everything's right! 🥕✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Adding hard coded accounts' accurately reflects the main changes: seed data now includes multiple hardcoded test users, and the login screen adds hardcoded account buttons for development mode.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch Adding_HardCoded_Accounts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
brightcleanproject/lib/features/auth/presentation/login_screen.dart (1)

102-105: Use a single source of truth for debug accounts.

These hardcoded credentials are duplicated here (Line 102–105) and in brightcleanproject/lib/core/database/database_helper.dart (Line 39–42). A mismatch will silently break quick-login for one or more roles.

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

In `@brightcleanproject/lib/features/auth/presentation/login_screen.dart` around
lines 102 - 105, The hardcoded debug credentials in the login screen are
duplicated elsewhere; consolidate them into a single source of truth (e.g.,
create a DebugAccounts const List/Map or add static debugAccounts on
DatabaseHelper) and have _debugLoginButton calls read from that single structure
instead of hardcoding values; update the other file that currently defines the
same credentials (the existing entries in DatabaseHelper) to reference the new
const so both login_screen._debugLoginButton and database initialization use the
same symbol (e.g., DebugAccounts or DatabaseHelper.debugAccounts) and remove the
duplicated literals from login_screen.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@brightcleanproject/lib/core/database/database_helper.dart`:
- Around line 37-47: The seeded test accounts (the testUsers list and the for
loop calling db.insert on 'users') must only run in debug builds: wrap the seed
creation and insertion logic in a debug-only guard (e.g., check Flutter's
kDebugMode or use an assert-based initialization) so it never executes in
release builds; keep the testUsers variable and insertion loop but move them
inside that guard (or bail out early if not debug) to prevent predictable
credentials from being inserted in production.

In `@brightcleanproject/lib/features/auth/presentation/login_screen.dart`:
- Around line 115-121: The delayed auto-login can call _handleLogin() after the
widget is disposed or allow overlapping logins; fix by replacing
Future.delayed(...) with a cancellable check that first verifies mounted and a
re-entry guard (e.g., bool _loginInProgress) before calling _handleLogin, and
cancel/ignore the delayed callback if the widget is disposed or _loginInProgress
is true; also ensure any code that force-unwraps controllers (referenced around
Line 36) is guarded to avoid null/crash scenarios.

---

Nitpick comments:
In `@brightcleanproject/lib/features/auth/presentation/login_screen.dart`:
- Around line 102-105: The hardcoded debug credentials in the login screen are
duplicated elsewhere; consolidate them into a single source of truth (e.g.,
create a DebugAccounts const List/Map or add static debugAccounts on
DatabaseHelper) and have _debugLoginButton calls read from that single structure
instead of hardcoding values; update the other file that currently defines the
same credentials (the existing entries in DatabaseHelper) to reference the new
const so both login_screen._debugLoginButton and database initialization use the
same symbol (e.g., DebugAccounts or DatabaseHelper.debugAccounts) and remove the
duplicated literals from login_screen.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fa3258bf-aad4-45ae-8ead-ac0099cfaf04

📥 Commits

Reviewing files that changed from the base of the PR and between 2421f82 and ab7f06b.

📒 Files selected for processing (2)
  • brightcleanproject/lib/core/database/database_helper.dart
  • brightcleanproject/lib/features/auth/presentation/login_screen.dart

Comment on lines +37 to +47
// Insert seed data for testing
final testUsers = [
{'phone': '0500000000', 'password': 'Password123', 'role': 'Admin'},
{'phone': '0511111111', 'password': 'Password123', 'role': 'Manager'},
{'phone': '0522222222', 'password': 'Password123', 'role': 'Customer'},
{'phone': '0533333333', 'password': 'Password123', 'role': 'Driver'},
];

for (var user in testUsers) {
await db.insert('users', user);
}
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 | 🔴 Critical

Restrict seeded test accounts to debug-only initialization.

Line 37–47 inserts predictable credentials unconditionally. That means release builds will still contain these accounts, which is a production auth backdoor and conflicts with the PR objective.

🔐 Suggested fix
 import 'package:sqflite/sqflite.dart';
 import 'package:path/path.dart';
+import 'package:flutter/foundation.dart';
@@
-    // Insert seed data for testing
-    final testUsers = [
-      {'phone': '0500000000', 'password': 'Password123', 'role': 'Admin'},
-      {'phone': '0511111111', 'password': 'Password123', 'role': 'Manager'},
-      {'phone': '0522222222', 'password': 'Password123', 'role': 'Customer'},
-      {'phone': '0533333333', 'password': 'Password123', 'role': 'Driver'},
-    ];
-    
-    for (var user in testUsers) {
-      await db.insert('users', user);
-    }
+    if (kDebugMode) {
+      final testUsers = [
+        {'phone': '0500000000', 'password': 'Password123', 'role': 'Admin'},
+        {'phone': '0511111111', 'password': 'Password123', 'role': 'Manager'},
+        {'phone': '0522222222', 'password': 'Password123', 'role': 'Customer'},
+        {'phone': '0533333333', 'password': 'Password123', 'role': 'Driver'},
+      ];
+
+      for (final user in testUsers) {
+        await db.insert('users', user, conflictAlgorithm: ConflictAlgorithm.ignore);
+      }
+    }
📝 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
// Insert seed data for testing
final testUsers = [
{'phone': '0500000000', 'password': 'Password123', 'role': 'Admin'},
{'phone': '0511111111', 'password': 'Password123', 'role': 'Manager'},
{'phone': '0522222222', 'password': 'Password123', 'role': 'Customer'},
{'phone': '0533333333', 'password': 'Password123', 'role': 'Driver'},
];
for (var user in testUsers) {
await db.insert('users', user);
}
if (kDebugMode) {
final testUsers = [
{'phone': '0500000000', 'password': 'Password123', 'role': 'Admin'},
{'phone': '0511111111', 'password': 'Password123', 'role': 'Manager'},
{'phone': '0522222222', 'password': 'Password123', 'role': 'Customer'},
{'phone': '0533333333', 'password': 'Password123', 'role': 'Driver'},
];
for (final user in testUsers) {
await db.insert('users', user, conflictAlgorithm: ConflictAlgorithm.ignore);
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@brightcleanproject/lib/core/database/database_helper.dart` around lines 37 -
47, The seeded test accounts (the testUsers list and the for loop calling
db.insert on 'users') must only run in debug builds: wrap the seed creation and
insertion logic in a debug-only guard (e.g., check Flutter's kDebugMode or use
an assert-based initialization) so it never executes in release builds; keep the
testUsers variable and insertion loop but move them inside that guard (or bail
out early if not debug) to prevent predictable credentials from being inserted
in production.

Comment thread brightcleanproject/lib/features/auth/presentation/login_screen.dart
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
brightcleanproject/lib/features/auth/presentation/login_screen.dart (1)

122-129: ⚠️ Potential issue | 🟠 Major

Disable debug chips during login and remove delayed trigger.

ActionChip is still tappable during an in-flight login. That allows credential fields to change while _handleLogin is running, and with the delayed callback this can produce unintended account login behavior. This is very close to the previously reported delayed auto-login concern.

Proposed fix
   Widget _debugLoginButton(String role, String phone, String password) {
     return ActionChip(
       label: Text(role),
-      onPressed: () {
+      onPressed: (_isLoading || _loginInProgress) ? null : () {
         _phoneController.text = phone;
         _passwordController.text = password;
-        // Small delay to ensure UI updates fields before logging in
-        Future.delayed(const Duration(milliseconds: 100), () {
-          if (!mounted || _loginInProgress) return;
-          _handleLogin();
-        });
+        _handleLogin();
       },
       backgroundColor: AppColors.primary.withOpacity(0.1),
       side: const BorderSide(color: AppColors.primary),
     );
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@brightcleanproject/lib/features/auth/presentation/login_screen.dart` around
lines 122 - 129, Remove the delayed trigger and prevent ActionChip taps while a
login is in progress: in the ActionChip onPressed handler (the one that
currently sets _phoneController.text/_passwordController.text and schedules
Future.delayed), stop using Future.delayed and instead immediately set the
controllers and then call _handleLogin() synchronously only if
!_loginInProgress; also ensure the ActionChip is disabled when _loginInProgress
is true (e.g., make onPressed null or short-circuit early based on
_loginInProgress) so taps cannot change credentials while _handleLogin is
running.
🧹 Nitpick comments (1)
brightcleanproject/lib/features/auth/presentation/login_screen.dart (1)

104-113: Avoid duplicating debug credentials in UI.

The seeded test accounts are duplicated here and in brightcleanproject/lib/core/database/database_helper.dart (Line 37-47). Centralize them in one debug config to prevent drift and broken quick-login buttons when seed data changes.

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

In `@brightcleanproject/lib/features/auth/presentation/login_screen.dart` around
lines 104 - 113, The login screen duplicates seeded test accounts that already
exist in DatabaseHelper; extract those credentials into a single shared constant
source (e.g., a DebugAccounts or DebugLoginConfig with a list of account
objects) and replace the hardcoded calls to _debugLoginButton in
login_screen.dart with a loop over that shared list; update database_helper.dart
to read its seed data from the same DebugAccounts constant so both
_debugLoginButton consumers and the seeder refer to one canonical definition.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@brightcleanproject/lib/features/auth/presentation/login_screen.dart`:
- Around line 122-129: Remove the delayed trigger and prevent ActionChip taps
while a login is in progress: in the ActionChip onPressed handler (the one that
currently sets _phoneController.text/_passwordController.text and schedules
Future.delayed), stop using Future.delayed and instead immediately set the
controllers and then call _handleLogin() synchronously only if
!_loginInProgress; also ensure the ActionChip is disabled when _loginInProgress
is true (e.g., make onPressed null or short-circuit early based on
_loginInProgress) so taps cannot change credentials while _handleLogin is
running.

---

Nitpick comments:
In `@brightcleanproject/lib/features/auth/presentation/login_screen.dart`:
- Around line 104-113: The login screen duplicates seeded test accounts that
already exist in DatabaseHelper; extract those credentials into a single shared
constant source (e.g., a DebugAccounts or DebugLoginConfig with a list of
account objects) and replace the hardcoded calls to _debugLoginButton in
login_screen.dart with a loop over that shared list; update database_helper.dart
to read its seed data from the same DebugAccounts constant so both
_debugLoginButton consumers and the seeder refer to one canonical definition.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 813a6769-4ae6-4215-91c6-142927654c7c

📥 Commits

Reviewing files that changed from the base of the PR and between ab7f06b and e319b33.

📒 Files selected for processing (1)
  • brightcleanproject/lib/features/auth/presentation/login_screen.dart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant