Securing Your App with One-Time Passwords (OTP)
A clean login page is only half the battle. Without proper authentication, anyone who knows a user’s email address can bypass boundaries and view private data. In this exercise, we will secure our application by implementing a robust One-Time Password (OTP) verification flow using Noca AI’s built-in security controls.
Follow this step-by-step guide to protect your private pages and configure an automated email verification loop.
Step 1: Identify the Security Gap
-
Open your existing project containing the LoginPage and AccountDetailsPage.
-
Notice that if a page is marked private but has no secondary verification (OTP) enabled, anyone entering an email address can instantly access the protected data. Let’s fix this vulnerability.
Step 2: Access Security Settings
-
In the top-right toolbar of the Noca workspace, click on the Settings (gear) icon.
-
From the settings modal sidebar, select the Security tab.
-
Verify your page rules:
-
LoginPageshould be set to Public. -
AccountDetailsPageshould be set to Private.
-
Step 3: Enable OTP Verification
-
Locate the OTP toggle under your authentication settings and switch it to On.
-
Click the Gear icon next to the OTP toggle to open the Configure OTP Email menu.
-
Optional: You can customize the subject line and email body here.
-
-
For this exercise, leave the default email copy as-is, click Apply, and then click the green Save button in the main settings modal.
-
Watch the workspace as Noca AI automatically generates a new secure page layout (
/verify) and configures the backend routing logic.
Step 4: Inspect the New Verification Page
-
Once the build completes, click the page dropdown in the top-left of your preview window.
-
Select the newly created VerifyPage (
/verify). -
Notice how Noca AI automatically styled the verification page to match your brand’s existing design language and login layouts.
Step 5: Test the Secure Login Flow
-
Click the Preview button in the top right to launch your live preview in a new tab.
-
On the Sign In screen, enter your email address and click Sign in to your account.
-
You will immediately be redirected to the secure
/verifypage, prompting you for a passcode. -
Check your email inbox. You will receive an automated message from Noca containing your temporary OTP passcode.
-
Copy the code, paste it into the One-time password input field in your preview browser, and click Verify code.
-
Upon successful verification, the app will securely redirect you to the restricted
AccountDetailsPage.