.
This commit is contained in:
+14
-1
@@ -22,7 +22,20 @@ export class SmsService {
|
||||
const raw = (
|
||||
this.config.get<string>('SMS_ENABLED', 'true') ?? 'true'
|
||||
).toLowerCase();
|
||||
return raw === '1' || raw === 'true' || raw === 'yes';
|
||||
const flagOn = raw === '1' || raw === 'true' || raw === 'yes';
|
||||
if (!flagOn) return false;
|
||||
return this.hasUsableSecret();
|
||||
}
|
||||
|
||||
private hasUsableSecret(): boolean {
|
||||
const secretKey = this.config.get<string>('SMS_SECRET_KEY')?.trim() ?? '';
|
||||
if (!secretKey) return false;
|
||||
const placeholders = new Set([
|
||||
'your-sms-secret-key',
|
||||
'کلید-پیامک',
|
||||
'change-me',
|
||||
]);
|
||||
return !placeholders.has(secretKey);
|
||||
}
|
||||
|
||||
async send(to: string, message: string): Promise<SmsSendResult> {
|
||||
|
||||
Reference in New Issue
Block a user