提交 af85fad7 编写于 作者: 雪洛's avatar 雪洛

fix: frv validator error

上级 7382e31f
......@@ -195,7 +195,7 @@ function isMatchUserApp (userAppList, matchAppList) {
}
function checkIdCard (idCardNumber) {
if (!idCardNumber) return false
if (!idCardNumber || typeof idCardNumber !== 'string') return false
const coefficient = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
const checkCode = [1, 0, 'x', 9, 8, 7, 6, 5, 4, 3, 2]
......
......@@ -148,7 +148,11 @@ module.exports = {
}
})
this.validator.mixin('realName', function (realName) {
if (!/^[\u4e00-\u9fa5]+$/.test(realName)) {
if (
typeof realName !== 'string' ||
realName.length < 2 ||
!/^[\u4e00-\u9fa5]{1,10}(·?[\u4e00-\u9fa5]{1,10}){0,5}$/.test(realName)
) {
return {
errCode: ERROR.INVALID_REAL_NAME
}
......
......@@ -68,53 +68,52 @@ module.exports = async function (params) {
}
}
if (res.authState === 'SUCCESS') {
const frvLogs = await frvLogsCollection.where({
certify_id: certifyId
}).get()
const log = frvLogs.data && frvLogs.data[0]
const updateData = {
realname_auth: {
auth_status: REAL_NAME_STATUS.CERTIFIED,
real_name: log.real_name,
identity: log.identity,
auth_date: Date.now(),
type: 0
}
if (res.authState !== 'SUCCESS') {
console.log(ERROR.UNKNOWN_ERROR, 'source res: ', res)
throw {
errCode: ERROR.UNKNOWN_ERROR
}
}
if (res.base64Photo) {
const {
fileID
} = await uniCloud.uploadFile({
cloudPath: `user/id-card/${uid}.bin`,
fileContent: Buffer.from(encryptData.call(this, res.base64Photo))
})
updateData.realname_auth.in_hand = fileID
}
const frvLogs = await frvLogsCollection.where({
certify_id: certifyId
}).get()
const log = frvLogs.data && frvLogs.data[0]
await Promise.all([
userCollection.doc(uid).update(updateData),
frvLogsCollection.where({
certify_id: certifyId
}).update({
status: REAL_NAME_STATUS.CERTIFIED
})
])
return {
errCode: 0,
authStatus: REAL_NAME_STATUS.CERTIFIED,
realName: dataDesensitization(decryptData.call(this, log.real_name), { onlyLast: true }),
identity: dataDesensitization(decryptData.call(this, log.identity))
const updateData = {
realname_auth: {
auth_status: REAL_NAME_STATUS.CERTIFIED,
real_name: log.real_name,
identity: log.identity,
auth_date: Date.now(),
type: 0
}
}
console.log(ERROR.UNKNOWN_ERROR, 'source res: ', res)
if (res.base64Photo) {
const {
fileID
} = await uniCloud.uploadFile({
cloudPath: `user/id-card/${uid}.bin`,
fileContent: Buffer.from(encryptData.call(this, res.base64Photo))
})
updateData.realname_auth.in_hand = fileID
}
await Promise.all([
userCollection.doc(uid).update(updateData),
frvLogsCollection.where({
certify_id: certifyId
}).update({
status: REAL_NAME_STATUS.CERTIFIED
})
])
throw {
errCode: ERROR.UNKNOWN_ERROR
return {
errCode: 0,
authStatus: REAL_NAME_STATUS.CERTIFIED,
realName: dataDesensitization(decryptData.call(this, log.real_name), { onlyLast: true }),
identity: dataDesensitization(decryptData.call(this, log.identity))
}
}
......@@ -53,6 +53,7 @@ module.exports = async function (params) {
}
const frvLogs = await frvLogsCollection.where({
user_id: uid,
real_name: realName,
identity: idCard,
status: REAL_NAME_STATUS.WAITING_CERTIFIED,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册