EKYC 3.0 — Login & Resume: Backend Developer Guide

Returning User Authentication, OTP Validation, Email OTP, Session Resume • Backend Implementation
Document Type: Backend Implementation Reference BRD Stage: Pre-Stage / Stage 2 (OTP Verification) Version: 1.0

Table of Contents

  1. Overview
  2. Existing API Endpoints
  3. AuthenticateLogin Flow
  4. OTP Generation & Validation Flows
  5. Email OTP Flow
  6. Resume / Redirect Flow
  7. Stored Procedures
  8. Database Tables
  9. External API Integrations
  10. BRD 3.0 Mapping & Gap Analysis

1. Overview

The Login module handles returning users resuming their EKYC journey. After registration, the user's OTP is verified via AuthenticateLogin, then the system determines which stage to redirect the user to. The module also handles email OTP generation/validation and session resume from any stage.

Existing Code Location D:\MO_Project\ekyc\existing_code\Joruney_imp_code\Registration\LoginController.cs
D:\MO_Project\ekyc\existing_code\Joruney_imp_code\Registration\LoginRepository.cs

2. Existing API Endpoints

Controller: LoginController — Route: api/Login/{action}

ActionHTTPAuthPurposeRepository Method
AUTHENTICATELOGINPOSTAnonymousMain login: validate mobile OTP, authenticate userAuthenticateLogin()
GENERATEOTPPOSTAnonymousGenerate and send mobile OTP for login/resumeGenerateOTP()
SENDSMSPOSTAnonymousSend SMS message (OTP or notification)SendSMS()
GETJWTTOKENIDPOSTAnonymousGenerate JWT token after authenticationGetJWTTokenId()
INITPOSTAuthorizedInitialize session, fetch client detailsGetClientDetails()
GETEMAILPOSTAuthorizedRetrieve email for authenticated userGetEmailDetails()
GETMOBILEPOSTAnonymousGet mobile number from requestGetMobile()
GetHolderMobileDetailsPOSTAuthorizedGet joint holder mobile detailsGetHolderMobileDetails()
GENERATEEMAILOTPPOSTAuthorizedGenerate OTP for email verificationGenerateEmailOTP()
VALIDATEOTPEMAILPOSTAuthorizedValidate email OTPValidateOTPEmail()
REDIRECTTOPAGEPOSTAnonymousGet next page for journey redirectRedirectToPage()
RESUMEFORMPOSTAuthorizedResume incomplete application formRESUMEFORM()
LEADDELETECLOUDPOSTAnonymousDelete lead from SuperApp cloudLEADDELETECLOUD()
ISALLOWREDIRECTPOSTAnonymousCheck if redirect is allowedIsAllowRedirect()
PUSHDATAINDRISHTIPOSTAuthorizedPush user data to Drishti systemPushDataInDrishti()

3. AuthenticateLogin Flow

Entry: LoginController.AUTHENTICATELOGIN()LoginRepository.AuthenticateLogin()

Step-by-Step Backend Execution

1
Log API EntryInsertUpdateAPI_Flagwise(userId, "Registration", "AUTHENTICATELOGIN")
2
Determine BRBA Login — If BranchEmpCode + AppLoginId present and IsDIY != "1", set IsBRBALogin = "1" (branch/RM assisted).
3
Check Offline Client_accountOpening.Check_Direct_Offline_Client_EXP(userId)
SP: [DIY].[USP_Check_Direct_Offline_Client_EXP_SJET]
If exists → block with message: "You are our existing client of {Branch} branch."
4
Decrypt Password/OTPDecrypt(_password) using AES decryption. The encrypted OTP from client is decrypted server-side.
5
Authenticate User_accountOpening.RESUME_AUTHENTICATE_USER_OTP_PASS(userId, decryptedOTP, uniqueId, isTruecaller, ...)
This calls OAO_SSO_AUTHENTICATE_USER or equivalent SP. Returns DataSet with user details if OTP matches.
6
Truecaller Handling — If isTruecaller == "1", validates Truecaller data and logs callback response.
7
Max Attempt Check — If authentication fails, increments failure counter. On max attempts exceeded, locks the account.
8
LeadSquare / Zoho Lead Creation — For DIRECT + Non-Zoho leads: Creates LSQ opportunity. Gets LSQ Lead ID. Creates activity log.
For Zoho leads: Handled via IsZohoLead flag from AppSettings.
9
Get Redirection PageUSP_GET_REDIRECTION_PAGENAME_SJET determines which stage/page the user should be redirected to based on their current progress.
10
Generate JWT Token_jWToken.GenerateEKYCToken() creates a JWT with UserId, BranchEmpCode, IsMobileApp, IPAddress, AppVersion, DeviceId, IsBRBALogin, AppName embedded as claims.
11
Return ResponseGetLoginDetails with: UserId, Status, Message, Token, PageName (redirect), LSQLeadId, OpportunityId, IsBRBALogin, ISSUPERAPP.

4. OTP Generation & Validation (Mobile)

4.1 Generate Mobile OTP

1
Validate mobile number format
2
Call SP: SEND_RESUME_OTP — generates OTP, stores in DB, returns unique identifier
3
Get SMS template from SMSTemplate
4
Send SMS via SingleMessageService.SingleMessageAsync() (SOAP)
5
Log SMS send to DB: [DIY].[USP_INSERT_SMS_SEND_API_LOG_SJET]

4.2 Validate Mobile OTP

1
Decrypt submitted OTP
2
Call SP: [DIY].[USP_VALIDATE_UPDATE_OTP_MOBILE_SJET] — compares submitted OTP with stored OTP, checks expiry, increments attempt counter
3
On success: Proceed to AuthenticateLogin flow
4
On failure: Return error with remaining attempts

5. Email OTP Flow

5.1 Generate Email OTP

1
Suspicious Email CheckUsp_GetSuspiciousPhoneOrEMailId checks if email is flagged
2
Domain Restriction[DIY].[USP_RESTRICT_EMAIL_DOMAIN_SJET] blocks restricted email domains
3
Real-time Email Validation — CYBRIDGE API validates email deliverability
4
Karza Email Validation — Secondary validation via Karza API
5
Bypass Check[DIY].[USP_BYPASS_MOBILE_EMAIL_PAN_SJET] with TYPE='EMAIL' — checks if email duplicate can be bypassed
6
Generate OTP — Random OTP generated. Stored via [DIY].[USP_SEND_RESUME_EMAILOTP_SJET]
7
Send EmailsendMail_Netcore() sends OTP email via Netcore email API

5.2 Validate Email OTP

1
Extract UserId from JWT token claims
2
Call [DIY].[USP_VALIDATE_UPDATE_OTP_EMAIL_SJET] — validates OTP, checks expiry, attempt limits
3
On success:
• Update email stage: [DIY].[USP_UPDATE_OTPEMAIL_STAGE_SJET]
• If ISSUPERAPP=1: Call SuperApp API for ClientCode generation
• Update StageDetails for tracking
4
Dedupe check: [DIY].[USP_CHECK_NINTY_DAY_LOGIC_LSQ_SJET] — 90-day logic
5
Return redirect page info via [DIY].[USP_GET_REDIRECTION_PAGENAME_SJET]

6. Resume / Redirect Flow

6.1 RESUMEFORM Endpoint

Used when a user returns to continue their incomplete application (via link, RM assistance, or telecaller).

1
Input: UserId, AdminId, TokenKey, IsTeleCaller, IsDIY, ReturnUrl, FailureReturnUrl
2
Call SP: [DIY].[USP_REDIRECT_EKYC_REVAMP_EXP_SJET]
3
SP fetches user's current stage, personal details, application status
4
Returns DataTable with all fields needed to pre-populate the form at the user's current stage

6.2 REDIRECTTOPAGE Endpoint

Determines which page/stage the user should be sent to based on their progress.

1
Call SP: [DIY].[USP_GET_REDIRECTION_PAGENAME_SJET]
2
SP checks TBL_CLIENT_STAGEDETAILS for last completed stage
3
Returns page name + metadata for the next step in the journey

7. Stored Procedures — Login & Resume

Stored ProcedureCalled FromPurposeKey Tables
RESUME_AUTHENTICATE_USER_OTP_PASS CORE AuthenticateLogin() Core authentication. Validates OTP/password against stored credentials. Returns user details DataSet. MOSL_SSO.tblUser TBL_DEDUPE_DATA_DUMP
[DIY].[USP_Check_Direct_Offline_Client_EXP_SJET] AuthenticateLogin() Checks if user is an existing offline client of a branch. If yes, blocks online journey. Back-office client tables
[DIY].[USP_GET_CLIENT_DETAILS_SJET] INIT endpoint Fetches full client profile for session initialization TBL_CLIENT_PERSONALDETAILS TBL_DEDUPE_DATA_DUMP
[DIY].[USP_GET_EMAIL_DETAILS_SJET] GETEMAIL endpoint Retrieves email address for authenticated user TBL_CLIENT_PERSONALDETAILS
[DIY].[USP_GET_MOBILE_DETAILS_SJET] GETMOBILE endpoint Retrieves mobile number details TBL_DEDUPE_DATA_DUMP
[DIY].[USP_VALIDATE_UPDATE_OTP_MOBILE_SJET] GenerateOTP / Validate Validates mobile OTP. Checks expiry and attempt counter. Updates on success/failure. OTP tracking table
[DIY].[USP_SEND_RESUME_EMAILOTP_SJET] GenerateEmailOTP() Stores email OTP in DB, returns OTP details Email OTP table
[DIY].[USP_VALIDATE_UPDATE_OTP_EMAIL_SJET] ValidateOTPEmail() Validates email OTP against stored value. Checks expiry and attempt limits. Email OTP table
[DIY].[USP_UPDATE_OTPEMAIL_STAGE_SJET] ValidateOTPEmail() Updates email validation stage after successful OTP verification TBL_CLIENT_STAGEDETAILS
[DIY].[USP_GET_REDIRECTION_PAGENAME_SJET] AuthenticateLogin(), REDIRECTTOPAGE Determines next page/stage based on user progress TBL_CLIENT_STAGEDETAILS
[DIY].[USP_REDIRECT_EKYC_REVAMP_EXP_SJET] RESUMEFORM Fetches all user data for form resumption. Supports DIY and telecaller flows. TBL_DEDUPE_DATA_DUMP TBL_CLIENT_PERSONALDETAILS TBL_OAO_DETAILS
[DIY].[USP_GET_CLIENT_DETAILS_EXP_SJET] LoginRepository Get expanded client details including all stage data Multiple client tables
[DIY].[USP_GET_APPSTATUS_SJET] LoginRepository Get application status (active, dropped, completed, etc.) TBL_OAO_DETAILS
[DIY].[USP_GET_ISOTPVISIBLEFORCOMPAIGN_SJET] LoginRepository Checks if OTP input should be visible for specific campaigns (some campaigns bypass OTP) TBL_APPLICATIONCONFIG
[DIY].[USP_INSERT_SMS_SEND_API_LOG_SJET] SendSMS() Logs SMS send attempts for audit and debugging SMS log table
[DIY].[USP_RESTRICT_EMAIL_DOMAIN_SJET] GenerateEmailOTP() Blocks restricted email domains (disposable email services, etc.) Domain restriction table
Usp_GetSuspiciousPhoneOrEMailId GenerateEmailOTP() Checks if phone/email is flagged as suspicious Suspicious list table
[DIY].[USP_CHECK_NINTY_DAY_LOGIC_LSQ_SJET] ValidateOTPEmail() 90-day dormant lead check against DAD-to-Retail transfer table Tbl_DAD_TO_RETAIL_TRANSFERRED_LEADS

8. Database Tables

TableUsed InPurpose
MOSL_SSO.dbo.tblUserAuthenticateLoginSSO authentication — stores encrypted credentials
TBL_DEDUPE_DATA_DUMPMultiplePrimary registration data. UserId lookup by mobile.
TBL_CLIENT_STAGEDETAILSRedirection, ResumeStage tracking — determines where user left off
TBL_CLIENT_PERSONALDETAILSINIT, ResumeClient personal data (name, address, PAN, etc.)
TBL_OAO_DETAILSResume, App StatusOpportunity/application details
TBL_LSQ_LEADID_STAGEDETAILSAuthenticateLoginLSQ lead tracking
Tbl_DAD_TO_RETAIL_TRANSFERRED_LEADS90-day checkDAD-to-Retail transfer tracking

9. External API Integrations

SystemPurposeWhen CalledFailure Handling
Netcore SMS (SOAP)OTP delivery via SingleMessageAsyncGENERATEOTPLogged to DB. Customer cannot proceed.
Netcore EmailEmail OTP delivery via sendMail_Netcore()GENERATEEMAILOTPLogged. Customer retries.
CYBRIDGEReal-time email deliverability validationGENERATEEMAILOTPSkip validation, proceed.
KarzaEmail validation (secondary)GENERATEEMAILOTPSkip, proceed.
LeadSquare CRMCreate opportunity, activity logAuthenticateLogin (DIRECT leads)Async retry. Lead exists locally.
Zoho CRMCreate/update leadAuthenticateLogin (Zoho leads)Token refresh + retry.
SuperApp APIClientCode generation, OtpKycDetails syncValidateOTPEmail (if ISSUPERAPP=1)Non-blocking. Synced later.
DrishtiPush user data for account openingPUSHDATAINDRISHTILogged. Retry.

10. BRD 3.0 Mapping & Gap Analysis

Key BRD Changes for Login/OTP Flow The BRD restructures login into Stage 2 (OTP Verification + Background Checks). The existing code's login flow maps partially but needs significant backend changes.
BRD 3.0 RequirementCurrent CodeGap
OTP stored in Redis only (TTL 5 min). Never written to DB. OTP stored in database via USP_VALIDATE_UPDATE_OTP_MOBILE_SJET HIGH — Migrate to Redis
Auto-submit on 4th digit (no Proceed button) Backend accepts OTP validation request regardless Backend OK — FE change only
5 wrong attempts → lead.state = DROPPED, DROP_OTP_LOCKED Max attempt logic exists but different state codes MEDIUM — Align codes
Max 3 resends in 30 min. 30-sec cooldown between resends. Rate limiting exists but thresholds may differ LOW — Config change
Background PAN checks (Zintlr, NSDL, CVL KRA) fire immediately after OTP verified PAN check happens at a later stage, not immediately after OTP HIGH — New parallel async pipeline
C-safe AML/PEP/SEBI check on PAN at Stage 2 USP_GETCSAFEFLAG_SJET exists but called later in journey MEDIUM — Move earlier
KRA status stored as raw CVL code + derived internal status KRA check exists but at PAN stage, not OTP stage HIGH — Restructure timing
Resume: OTP sent to registered mobile → verified → return to last completed stage RESUMEFORM + USP_REDIRECT_EKYC_REVAMP_EXP_SJET handles resume LOW — Existing, enhance
JWT token with UserId, session claims GenerateEKYCToken() already creates JWT with all needed claims OK — Existing
Email OTP at Stage 3 (separate from mobile OTP) GENERATEEMAILOTP + VALIDATEOTPEMAIL exist LOW — Reuse with BRD alignment
Architecture Recommendation for EKYC 3.0 The BRD requires background PAN/KRA checks to fire immediately after OTP verification (Stage 2), running in parallel while the customer moves to Stage 3 (Email). This requires:
1. An async job/message queue (e.g., RabbitMQ, Azure Service Bus) triggered on OTP_VERIFIED
2. Workers calling Zintlr, Hyperverge, NSDL, CVL KRA, C-safe in parallel
3. Results stored on the lead record, consumed at Stage 4
4. The existing IBackgroundTaskQueue in the codebase could potentially be extended for this.