In the landscape of modern cybersecurity, protecting user accounts from brute-force attacks is non-negotiable. One of the most effective ways to mitigate these risks is by implementing a robust Account Lockout Policy. This feature ensures that even if an attacker has a partial piece of the puzzle (like a username), they cannot infinitely guess the password without consequences.
Here is a breakdown of how to implement a sophisticated lockout and recovery workflow.
1. The Trigger: Identifying and Tracking Failed Attempts
The process begins the moment a user enters their credentials. Security is a balance, we want to protect the user without creating unnecessary friction.
Username Verification: The system only begins tracking failed attempts if the username exists. This prevents "ghost" tracking for non-existent accounts, though the front-end should always return a generic error message to prevent username enumeration.
The "3+2" Notification Rule: * At 3 failed attempts: Inform the user with a warning: "You have 2 attempts remaining before your account is locked for security reasons."
At 5 failed attempts: Formally lock the account.
Success Resets the Clock: If a user enters the correct password on the 4th attempt, the system will immediately reset the failed attempt count to zero.
2. The Locked State: Strict Access Control
Once an account is flagged as "Locked," the login gateway changes its behavior to prioritize security over validation.
Total Restriction: If the account is locked, the system will not even check the password. Whether the user enters the correct or incorrect credentials, the response remains the same: "Your account is locked."
Automated Recovery: Upon the 5th failed attempt, the system triggers an automated security email.
System Message: "An email with instructions to unlock your account has been sent. Please follow the steps in the email to regain access."
3. The Road to Recovery: Unlocking the Account
Providing a clear path back to access is vital for user experience. We utilize two primary methods: Self-Service and Administrative Intervention.
Self-Service (Token-Based)
The automated email contains a unique, time-sensitive unlock_token.
The user clicks the link.
The system verifies the token against the database.
Upon successful verification, the system allows the users to login.
Administrative Management
For internal teams, visibility is key. Administrators need to see which users are currently sidelined.
UI Indicators: A prominent "Account Locked" badge should appear in user listing tables and individual profile pages.
Manual Override: Administrators can click an "Unlock" button to restore access immediately without waiting for a token verification.
4. Hierarchy of Permissions
To maintain organization security, the ability to unlock accounts must follow a strict permission structure:
User Role | Can Unlock... |
Main Admin | Other Admins, Teachers, Students, and Parents. |
Sub-Admin (with permissions) | Teachers, Students, and Parents. |
Teacher/Student/Parent | Self-unlock via email only. |
The "Lone Admin" Exception: If a tenant has only one Super Admin and that account becomes locked, the automated email is the primary recovery path. If that fails, the Admin must contact the system provider support directly for identity verification and manual restoration.
Questions? Write us to [email protected]
OR use in-app chat tool




