Secure Login and Two-Factor Authentication: A Guide for Web Applications

Most business applications, from CRM and billing software to MLM back offices and recharge portals, hold money, personal data or both. The login screen is the front door. If it is weak, every other security measure matters much less. This guide explains what a secure login looks like and how two-factor authentication (2FA) adds a second lock.

How passwords should be stored

A well-built application never stores passwords in readable form, and never in a form that can be reversed. Instead it stores a hash: a one-way fingerprint produced by a slow, purpose-built algorithm such as bcrypt or Argon2, with a unique random value (a "salt") for each user. When someone logs in, the system hashes what they typed and compares fingerprints.

If your developer can tell you a user's password, or a "forgot password" email sends the old password, the storage is not secure and should be fixed urgently.

Sensible password rules

  • Encourage long passwords or passphrases rather than complicated short ones.
  • Block commonly used and previously breached passwords where possible.
  • Do not force frequent password changes without reason; it tends to produce weaker passwords.
  • Allow paste, so people can use password managers.

Stop guessing attacks

Automated tools try thousands of password combinations, or reuse passwords leaked from other sites ("credential stuffing"). Defences include:

  • Rate limiting: slow down or temporarily block repeated failed attempts from the same account or network address.
  • Generic error messages: "Incorrect mobile number or password" rather than revealing which part was wrong.
  • Alerts: notify users of logins from new devices.
  • Challenge on suspicion: ask for extra verification when behaviour looks unusual.

Sessions after login

Once logged in, the user's session must be protected too. Session cookies should be marked secure and HTTP-only, sessions should expire after inactivity (shorter for admin panels), and changing a password should sign out other sessions. Users should be able to see and end their active sessions.

Two-factor authentication options

2FA means proving identity with two different things: something you know (a password) and something you have (a phone or device). Common methods:

MethodHow it worksConsiderations
SMS OTPOne-time code sent by SMSFamiliar to users in India; depends on SMS delivery and is weaker against SIM swap
Email OTPCode sent to registered emailSimple; only as safe as the email account
Authenticator app (TOTP)Time-based code generated in an app on the phoneStronger; works offline; needs one-time setup
Security keys / passkeysDevice-based cryptographic loginStrongest against phishing; growing support

For many business applications, a practical approach is authenticator-app 2FA required for admins and staff, with SMS OTP available for customers. If you need reliable OTP delivery, see our OTP SMS API.

Account recovery: the hidden back door

Attackers often skip the login and target "forgot password" instead. Good recovery flows:

  1. Send a single-use, time-limited reset link or code.
  2. Do not reveal whether an account exists for a given email or number.
  3. Notify the user after a password change.
  4. Provide backup codes when 2FA is enabled, so a lost phone does not mean a lost account.
  5. Require stronger checks for admin account recovery.

Extra protection for admin panels

  • Mandatory 2FA for every admin and staff account.
  • Role-based permissions so staff see only what they need.
  • Re-confirmation (password or OTP) before sensitive actions such as changing payout bank details or exporting data.
  • Optional restriction of admin access to known networks.
  • Logs of every admin login and sensitive action.

Example

Gurpreet runs a recharge distribution portal with several hundred retailers. One retailer's account was accessed using a password they had reused on another site, and the wallet balance was misused. After the incident, we added authenticator-app 2FA for distributors, login alerts by SMS, device session lists and OTP confirmation before wallet transfers above a set amount. Retailers found the extra step acceptable once it was explained.

Login security checklist

  • Passwords hashed with a modern, slow algorithm.
  • Rate limiting on login, OTP and reset endpoints.
  • 2FA available for all and mandatory for admins.
  • Secure, expiring sessions.
  • Safe recovery flow with notifications.
  • Login and admin activity logged.

Strengthen your login

We build secure authentication into every web application and can add 2FA to existing systems. Our audit service also reviews login and session handling. Talk to our team to get started.

0 comments

Leave a comment

Not shown publicly.
Security check image
Chat with us
Hi! Send us a message and we will reply here as soon as we can.
Security check image
Chat with us