Skip to content

Conversation

@smarcet
Copy link
Collaborator

@smarcet smarcet commented Jul 11, 2025

Change-Id: Icd5ceb7f886ffa918449c872047ce4f279ee9c81
ref https://tipit.avaza.com/project/view/376250#!tab=task-pane&task=3818781

Change-Id: Icd5ceb7f886ffa918449c872047ce4f279ee9c81
@smarcet smarcet requested review from Copilot and romanetar July 11, 2025 21:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a login attempt counter, exposes related session variables to the frontend, and updates backend logic to track and reset failed attempts.

  • Add max_login_failed_attempts and user_is_active session values in the login view
  • Enhance React form to display dynamic error messages based on login attempt counts and lock status
  • Persist and reset login_failed_attempt in the user model and propagate values via the controller

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
resources/views/auth/login.blade.php Inject new session variables (maxLoginFailedAttempts, user_is_active) into JS config
resources/js/login/login.js Use loginAttempts, maxLoginFailedAttempts, and userIsActive to conditionally render errors
app/libs/Auth/Models/User.php Initialize login_failed_attempt in activate() and verifyEmail()
app/libs/Auth/Factories/UserFactory.php Remove unused import
app/Services/SecurityPolicies/LockUserCounterMeasure.php Simplify null check on $user
app/Http/Controllers/UserController.php Expose new config values (max_login_failed_attempts, user_is_active) in JSON responses
Comments suppressed due to low confidence (4)

resources/views/auth/login.blade.php:70

  • The config property uses snake_case (user_is_active) while other properties use camelCase. Rename to userIsActive for consistency with the rest of the JS config.
            config.user_is_active = {{Session::get("user_is_active")}};

app/Http/Controllers/UserController.php:513

  • The value for user_verified is sometimes a boolean (true) and sometimes an integer (1). For consistency and clearer API design, use a boolean in all cases.
                $response_data['user_verified'] = 1;

app/libs/Auth/Models/User.php:1857

  • Setting login_failed_attempt to 10 in activate() may immediately lock the user again. Verify whether this should be reset to 0 instead to fully clear prior failures.
            $this->login_failed_attempt = 10;

resources/js/login/login.js:819

  • Server response keys are snake_case (login_attempts, max_login_failed_attempts) but props are accessed as camelCase. This mismatch may cause undefined values; ensure prop names align with the data shape (either rename server keys or adjust prop accessors).
                                    loginAttempts={this.props?.loginAttempts}

Copy link
Contributor

@romanetar romanetar left a comment

Choose a reason for hiding this comment

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

@smarcet please review comments

if(!$this->active) {
$this->active = true;
$this->spam_type = self::SpamTypeHam;
$this->login_failed_attempt = 10;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please extract this to a constant

Copy link
Contributor

@romanetar romanetar left a comment

Choose a reason for hiding this comment

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

LGTM

Change-Id: Ib765702819565ec82e1bc60361aee27aa492350b
@smarcet smarcet merged commit f4ab6eb into hotfix/user-prevalidation-feedback Jul 14, 2025
1 check passed
smarcet added a commit that referenced this pull request Jul 14, 2025
…78)

* feat: propagate can_login to UI and give more feedback

Signed-off-by: romanetar <[email protected]>

* feat: add more feedback to UI on inactive and/or unverified accounts

Signed-off-by: romanetar <[email protected]>

* fix: login flow ui tweaks

Signed-off-by: romanetar <[email protected]>

* fix: PR review feedback

Signed-off-by: romanetar <[email protected]>

* feat: add login attempt counter (#82)

* feat: add login attempt counter

Change-Id: Icd5ceb7f886ffa918449c872047ce4f279ee9c81

* fix: remove hard coded test value

Change-Id: Ib765702819565ec82e1bc60361aee27aa492350b

---------

Signed-off-by: romanetar <[email protected]>
Co-authored-by: sebastian marcet <[email protected]>
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.

3 participants