@@ -53,14 +53,21 @@ final class ApplicationService {
|
||||
return $this->view($existing);
|
||||
}
|
||||
|
||||
$public_name = sanitize_text_field((string) ($input['public_name'] ?? ''));
|
||||
$public_desc = sanitize_textarea_field((string) ($input['public_desc'] ?? ''));
|
||||
if ($this->length($public_name) < 2 || $this->length($public_name) > 64 || $this->length($public_desc) > 300) {
|
||||
return new \WP_Error('aksrt_identity_public_info', __('认证展示信息长度无效', 'aksrt'));
|
||||
$person_name = sanitize_text_field((string) ($input['person_name'] ?? ''));
|
||||
$id_number = preg_replace('/\s+/', '', sanitize_text_field((string) ($input['id_number'] ?? ''))) ?: '';
|
||||
$company_name = $type === 'enterprise' ? sanitize_text_field((string) ($input['company_name'] ?? '')) : '';
|
||||
$company_code = $type === 'enterprise' ? (preg_replace('/\s+/', '', sanitize_text_field((string) ($input['company_code'] ?? ''))) ?: '') : '';
|
||||
if ($person_name === '' || $this->length($person_name) > 50 || $id_number === '' || $this->length($id_number) > 20) {
|
||||
return new \WP_Error('aksrt_identity_person_fields', __('请填写有效的姓名和身份证号码', 'aksrt'));
|
||||
}
|
||||
if ($type === 'enterprise' && ($company_name === '' || $this->length($company_name) > 191 || $company_code === '' || $this->length($company_code) > 32)) {
|
||||
return new \WP_Error('aksrt_identity_enterprise_fields', __('请填写有效的企业全称和统一社会信用代码', 'aksrt'));
|
||||
}
|
||||
if (empty($input['consent'])) {
|
||||
return new \WP_Error('aksrt_identity_consent', __('请先同意身份信息处理说明', 'aksrt'));
|
||||
}
|
||||
$public_name = $type === 'enterprise' ? $this->truncate($company_name, 64) : __('个人认证', 'aksrt');
|
||||
$public_desc = '';
|
||||
|
||||
$type_settings = \AKSRT\User\AuthApply::type_settings($type);
|
||||
$attempt = $this->applications->count_user_type($user_id, $type);
|
||||
@@ -75,12 +82,12 @@ final class ApplicationService {
|
||||
'provider_flow' => (string) $settings['personal_flow'],
|
||||
'public_name' => $public_name,
|
||||
'public_desc' => $public_desc,
|
||||
'person_name_masked' => SettingsRuntime::mask_name((string) ($input['person_name'] ?? '')),
|
||||
'id_number_masked' => SettingsRuntime::mask_id_number((string) ($input['id_number'] ?? '')),
|
||||
'id_number_hash' => !empty($input['id_number']) ? SettingsRuntime::hmac((string) $input['id_number']) : '',
|
||||
'company_name' => $type === 'enterprise' ? sanitize_text_field((string) ($input['company_name'] ?? '')) : '',
|
||||
'company_code_masked' => $type === 'enterprise' ? SettingsRuntime::mask_id_number((string) ($input['company_code'] ?? '')) : '',
|
||||
'company_code_hash' => $type === 'enterprise' && !empty($input['company_code']) ? SettingsRuntime::hmac((string) $input['company_code']) : '',
|
||||
'person_name_masked' => SettingsRuntime::mask_name($person_name),
|
||||
'id_number_masked' => SettingsRuntime::mask_id_number($id_number),
|
||||
'id_number_hash' => SettingsRuntime::hmac($id_number),
|
||||
'company_name' => $company_name,
|
||||
'company_code_masked' => $type === 'enterprise' ? SettingsRuntime::mask_id_number($company_code) : '',
|
||||
'company_code_hash' => $type === 'enterprise' ? SettingsRuntime::hmac($company_code) : '',
|
||||
'fee_amount' => $fee,
|
||||
'fee_status' => $fee > 0 ? 'pending' : 'not_required',
|
||||
'attempt_ordinal' => $attempt + 1,
|
||||
@@ -101,6 +108,10 @@ final class ApplicationService {
|
||||
}
|
||||
|
||||
$provider_request = $input;
|
||||
$provider_request['person_name'] = $person_name;
|
||||
$provider_request['id_number'] = $id_number;
|
||||
$provider_request['company_name'] = $company_name;
|
||||
$provider_request['company_code'] = $company_code;
|
||||
$provider_request['application_uuid'] = $application['application_uuid'];
|
||||
$provider_request['user_id'] = $user_id;
|
||||
$result = $type === 'personal'
|
||||
@@ -283,4 +294,8 @@ final class ApplicationService {
|
||||
private function length(string $value): int {
|
||||
return function_exists('mb_strlen') ? mb_strlen($value) : strlen($value);
|
||||
}
|
||||
|
||||
private function truncate(string $value, int $length): string {
|
||||
return function_exists('mb_substr') ? mb_substr($value, 0, $length) : substr($value, 0, $length);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user