@@ -33,6 +33,18 @@ function isAliyunConfigMissing(config: AppConfig['smsAuth']) {
|
||||
return !config.accessKeyId || !config.accessKeySecret;
|
||||
}
|
||||
|
||||
function assertAliyunRequiredConfig(config: AppConfig['smsAuth']) {
|
||||
if (!config.signName.trim()) {
|
||||
throw new Error('ALIYUN_SMS_SIGN_NAME 未配置');
|
||||
}
|
||||
if (!config.templateCode.trim()) {
|
||||
throw new Error('ALIYUN_SMS_TEMPLATE_CODE 未配置');
|
||||
}
|
||||
if (!config.templateParamKey.trim()) {
|
||||
throw new Error('ALIYUN_SMS_TEMPLATE_PARAM_KEY 未配置');
|
||||
}
|
||||
}
|
||||
|
||||
function buildProviderErrorMessage(prefix: string, message: string) {
|
||||
const normalizedMessage = message.trim();
|
||||
return normalizedMessage ? `${prefix}:${normalizedMessage}` : prefix;
|
||||
@@ -48,6 +60,7 @@ class AliyunSmsVerificationService implements SmsVerificationService {
|
||||
if (isAliyunConfigMissing(config)) {
|
||||
throw new Error('ALIYUN_SMS_ACCESS_KEY_ID 或 ALIYUN_SMS_ACCESS_KEY_SECRET 未配置');
|
||||
}
|
||||
assertAliyunRequiredConfig(config);
|
||||
|
||||
const clientConfig = new OpenApiClient.Config({
|
||||
accessKeyId: config.accessKeyId,
|
||||
|
||||
Reference in New Issue
Block a user