MukeshKapoor25 commited on
Commit
a22c439
Β·
1 Parent(s): e9ff13c

chore(config): Update WATI customer OTP template name

Browse files

- Change WATI_OTP_TEMPLATE_NAME from 'customer_otp_login' to 'cust_otp' in configuration
- Update .env.example with new template name
- Update README.md documentation with new template name
- Update STAFF_WATI_OTP_INTEGRATION.md comparison table with new template name
- Update verify_wati_token.py verification script with new template name
- Remove unused customer_otps collection index initialization from db_init_customer.py
- Align all references to use standardized template naming convention

.env.example CHANGED
@@ -50,7 +50,7 @@ TWILIO_PHONE_NUMBER=
50
  # WATI WhatsApp API Configuration (for WhatsApp OTP)
51
  WATI_API_ENDPOINT=https://live-mt-server.wati.io/YOUR_TENANT_ID
52
  WATI_ACCESS_TOKEN=your-wati-bearer-token
53
- WATI_OTP_TEMPLATE_NAME=customer_otp_login
54
  WATI_STAFF_OTP_TEMPLATE_NAME=staff_otp_login
55
 
56
  # SMTP Configuration (for email notifications)
 
50
  # WATI WhatsApp API Configuration (for WhatsApp OTP)
51
  WATI_API_ENDPOINT=https://live-mt-server.wati.io/YOUR_TENANT_ID
52
  WATI_ACCESS_TOKEN=your-wati-bearer-token
53
+ WATI_OTP_TEMPLATE_NAME=cust_otp
54
  WATI_STAFF_OTP_TEMPLATE_NAME=staff_otp_login
55
 
56
  # SMTP Configuration (for email notifications)
README.md CHANGED
@@ -142,7 +142,7 @@ TOKEN_EXPIRATION_HOURS=8
142
  # WATI WhatsApp API (for Customer OTP)
143
  WATI_API_ENDPOINT=https://live-mt-server.wati.io/YOUR_TENANT_ID
144
  WATI_ACCESS_TOKEN=your-wati-bearer-token
145
- WATI_OTP_TEMPLATE_NAME=customer_otp_login
146
  ```
147
 
148
  See `.env.example` for complete configuration options.
@@ -161,7 +161,7 @@ Both customer and staff authentication use WATI WhatsApp API to send OTP codes v
161
 
162
  2. **Create Authentication Templates**
163
 
164
- **Customer Template:** `customer_otp_login`
165
  ```
166
  Your OTP for login is: {{otp_code}}
167
  This code will expire in {{expiry_time}} minutes.
 
142
  # WATI WhatsApp API (for Customer OTP)
143
  WATI_API_ENDPOINT=https://live-mt-server.wati.io/YOUR_TENANT_ID
144
  WATI_ACCESS_TOKEN=your-wati-bearer-token
145
+ WATI_OTP_TEMPLATE_NAME=cust_otp
146
  ```
147
 
148
  See `.env.example` for complete configuration options.
 
161
 
162
  2. **Create Authentication Templates**
163
 
164
+ **Customer Template:** `cust_otp`
165
  ```
166
  Your OTP for login is: {{otp_code}}
167
  This code will expire in {{expiry_time}} minutes.
STAFF_WATI_OTP_INTEGRATION.md CHANGED
@@ -262,7 +262,7 @@ Status: 401
262
  | Feature | Customer OTP | Staff OTP |
263
  |---------|-------------|-----------|
264
  | Collection | `customer_otps` | `staff_otps` |
265
- | Template | `customer_otp_login` | `staff_otp_login` |
266
  | User Validation | Find or create customer | Must exist as staff user |
267
  | Role Check | N/A | Must be staff (not admin) |
268
  | Status Check | N/A | Must be active |
 
262
  | Feature | Customer OTP | Staff OTP |
263
  |---------|-------------|-----------|
264
  | Collection | `customer_otps` | `staff_otps` |
265
+ | Template | `cust_otp` | `staff_otp_login` |
266
  | User Validation | Find or create customer | Must exist as staff user |
267
  | Role Check | N/A | Must be staff (not admin) |
268
  | Status Check | N/A | Must be active |
app/auth/db_init_customer.py CHANGED
@@ -33,21 +33,6 @@ async def init_customer_auth_collections():
33
 
34
  logger.info("βœ… scm_customers collection indexes created")
35
 
36
- # Create indexes for customer_otps collection
37
- otps_collection = db.customer_otps
38
-
39
- # Index on mobile for fast lookup
40
- await otps_collection.create_index("mobile", unique=True)
41
-
42
- # TTL index on expires_at for automatic cleanup
43
- await otps_collection.create_index("expires_at", expireAfterSeconds=0)
44
-
45
- # Index on created_at for cleanup queries
46
- await otps_collection.create_index("created_at")
47
-
48
- logger.info("βœ… customer_otps collection indexes created")
49
-
50
- logger.info("πŸŽ‰ Customer authentication database initialization completed")
51
 
52
  except Exception as e:
53
  logger.error(f"❌ Error initializing customer auth collections: {str(e)}", exc_info=True)
 
33
 
34
  logger.info("βœ… scm_customers collection indexes created")
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  except Exception as e:
38
  logger.error(f"❌ Error initializing customer auth collections: {str(e)}", exc_info=True)
app/core/config.py CHANGED
@@ -60,7 +60,7 @@ class Settings(BaseSettings):
60
  # WATI WhatsApp API Configuration
61
  WATI_API_ENDPOINT: str = os.getenv("WATI_API_ENDPOINT", "https://live-mt-server.wati.io/104318")
62
  WATI_ACCESS_TOKEN: str = os.getenv("WATI_ACCESS_TOKEN", "")
63
- WATI_OTP_TEMPLATE_NAME: str = os.getenv("WATI_OTP_TEMPLATE_NAME", "customer_otp_login")
64
  WATI_STAFF_OTP_TEMPLATE_NAME: str = os.getenv("WATI_STAFF_OTP_TEMPLATE_NAME", "staff_otp_login")
65
 
66
  # SMTP Configuration
 
60
  # WATI WhatsApp API Configuration
61
  WATI_API_ENDPOINT: str = os.getenv("WATI_API_ENDPOINT", "https://live-mt-server.wati.io/104318")
62
  WATI_ACCESS_TOKEN: str = os.getenv("WATI_ACCESS_TOKEN", "")
63
+ WATI_OTP_TEMPLATE_NAME: str = os.getenv("WATI_OTP_TEMPLATE_NAME", "cust_otp")
64
  WATI_STAFF_OTP_TEMPLATE_NAME: str = os.getenv("WATI_STAFF_OTP_TEMPLATE_NAME", "staff_otp_login")
65
 
66
  # SMTP Configuration
verify_wati_token.py CHANGED
@@ -167,7 +167,7 @@ async def verify_wati_token():
167
 
168
  print("\n2. If token is valid but getting 403:")
169
  print(" - Check WATI dashboard > API > Logs for error details")
170
- print(" - Verify template 'customer_otp_login' is approved")
171
  print(" - Check if API access is enabled for your account")
172
  print(" - Contact WATI support if issue persists")
173
 
 
167
 
168
  print("\n2. If token is valid but getting 403:")
169
  print(" - Check WATI dashboard > API > Logs for error details")
170
+ print(" - Verify template 'cust_otp' is approved")
171
  print(" - Check if API access is enabled for your account")
172
  print(" - Contact WATI support if issue persists")
173