<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: RollHire</title>
    <description>The latest articles on DEV Community by RollHire (@rollhire).</description>
    <link>https://dev.to/rollhire</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4258870%2F13c0739b-d22f-4e57-9f8d-926d3d32a885.png</url>
      <title>DEV Community: RollHire</title>
      <link>https://dev.to/rollhire</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rollhire"/>
    <language>en</language>
    <item>
      <title>WhatsApp OTP login with SMS fallback: 3 bugs that cost us sign-ups</title>
      <dc:creator>RollHire</dc:creator>
      <pubDate>Sun, 22 Nov 2026 14:23:20 +0000</pubDate>
      <link>https://dev.to/rollhire/whatsapp-otp-login-with-sms-fallback-3-bugs-that-cost-us-sign-ups-2aip</link>
      <guid>https://dev.to/rollhire/whatsapp-otp-login-with-sms-fallback-3-bugs-that-cost-us-sign-ups-2aip</guid>
      <description>&lt;p&gt;Most of our users in India are delivery riders, guards, pickers and telecallers signing up on budget Android phones. SMS OTP was our biggest sign-up leak: messages arrived late or not at all, and every resend cost money. We moved the primary OTP channel to WhatsApp and kept SMS as a fallback. Here's how it works and the bugs we hit.&lt;/p&gt;

&lt;h2&gt;
  
  
  The flow
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;The client calls a serverless function &lt;code&gt;/send&lt;/code&gt; with the phone number.&lt;/li&gt;
&lt;li&gt;The function normalises the number to E.164, finds or creates the auth user, generates a 6-digit code, and sends it through a WhatsApp Business authentication template.&lt;/li&gt;
&lt;li&gt;Only a SHA-256 hash of &lt;code&gt;userId:code&lt;/code&gt; is stored in the user's prefs, with an expiry and an attempt counter.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/verify&lt;/code&gt; compares hashes, counts attempts, and on success mints a short-lived session token the client exchanges for a session.&lt;/li&gt;
&lt;li&gt;If WhatsApp delivery fails, &lt;code&gt;/send&lt;/code&gt; returns &lt;code&gt;{ fallback: "sms" }&lt;/code&gt; and the client falls back to the platform's SMS OTP.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Rate limits that don't lock real users out
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A per-number minimum gap between sends, and a cap per hour.&lt;/li&gt;
&lt;li&gt;A global cap per hour as a cost circuit-breaker.&lt;/li&gt;
&lt;li&gt;Attempt slots claimed as documents with deterministic IDs (&lt;code&gt;challengeId-attempt&lt;/code&gt;), so parallel verify requests can't bypass the 5-attempt limit.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Bug 1: the keyboard was entering the wrong code
&lt;/h2&gt;

&lt;p&gt;Our OTP input had &lt;code&gt;autocomplete="one-time-code"&lt;/code&gt;. On Android, the keyboard then suggests the latest &lt;strong&gt;SMS&lt;/strong&gt; code it has seen, often an old bank or delivery OTP. Combined with auto-submit at 6 digits, users "entered" a wrong code without typing anything. Fix: only set &lt;code&gt;one-time-code&lt;/code&gt; when the channel is SMS; use &lt;code&gt;off&lt;/code&gt; for WhatsApp.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bug 2: resend cancelled the code people were typing
&lt;/h2&gt;

&lt;p&gt;Each send overwrote the stored hash. WhatsApp messages sometimes arrive out of order, so users typed the first code after tapping resend and got "wrong OTP". Fix: keep the last two unexpired hashes alongside the new one and accept any of them until their own expiry.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bug 3: placeholder numbers
&lt;/h2&gt;

&lt;p&gt;People type 9876543210 or 1234567890 to see what happens. That sends a real message to a stranger and leaves the user stuck. We now reject well-known placeholder numbers before sending, with a clear message.&lt;/p&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;p&gt;Wrong-OTP errors dropped right after these fixes, and WhatsApp delivery is noticeably faster than SMS for our users.&lt;/p&gt;

&lt;p&gt;If you're curious about the product, it's &lt;a href="https://rollhire.com" rel="noopener noreferrer"&gt;RollHire&lt;/a&gt;, a hiring app for local jobs in India.&lt;/p&gt;

</description>
      <category>android</category>
      <category>startup</category>
    </item>
  </channel>
</rss>
