diff --git a/controllers/resource.go b/controllers/resource.go index b697c4d6..5156ae9a 100644 --- a/controllers/resource.go +++ b/controllers/resource.go @@ -207,7 +207,7 @@ func (c *ApiController) UploadResource() { } fullFilePath = object.GetTruncatedPath(provider, fullFilePath, 175) - if tag != "avatar" && tag != "termsOfUse" { + if tag != "avatar" && tag != "termsOfUse" && !strings.HasPrefix(tag, "idCard") { ext := filepath.Ext(filepath.Base(fullFilePath)) index := len(fullFilePath) - len(ext) for i := 1; ; i++ { @@ -307,6 +307,25 @@ func (c *ApiController) UploadResource() { c.ResponseError(err.Error()) return } + case "idCardFront", "idCardBack", "idCardWithPerson": + user, err := object.GetUserNoCheck(util.GetId(owner, username)) + if err != nil { + c.ResponseError(err.Error()) + return + } + + if user == nil { + c.ResponseError(c.T("resource:User is nil for tag: avatar")) + return + } + + user.Properties[tag] = fileUrl + user.Properties["isIdCardVerified"] = "false" + _, err = object.UpdateUser(user.GetId(), user, []string{"properties"}, false) + if err != nil { + c.ResponseError(err.Error()) + return + } } c.ResponseOk(fileUrl, objectKey) diff --git a/web/src/UserEditPage.js b/web/src/UserEditPage.js index 6e8982aa..5c2003b8 100644 --- a/web/src/UserEditPage.js +++ b/web/src/UserEditPage.js @@ -53,6 +53,8 @@ class UserEditPage extends React.Component { mode: props.location.mode !== undefined ? props.location.mode : "edit", loading: true, returnUrl: null, + idCardInfo: ["ID card front", "ID card back", "ID card with person"], + idCardKey: ["idCardFront", "idCardBack", "idCardWithPerson"], }; } @@ -269,6 +271,12 @@ class UserEditPage extends React.Component { } } + if (accountItem.name === "ID card info" || accountItem.name === "ID card") { + if (this.state.user.properties?.isIdCardVerified === "true") { + disabled = true; + } + } + let isKeysGenerated = false; if (this.state.user.accessKey !== "" && this.state.user.accessKey !== "") { isKeysGenerated = true; @@ -365,20 +373,11 @@ class UserEditPage extends React.Component { {Setting.getLabel(i18next.t("general:Avatar"), i18next.t("general:Avatar - Tooltip"))} : - - - - {i18next.t("general:Preview")}: - - - - {this.state.user.avatar} - - - - - organization.name === this.state.organizationName)} /> - + + {i18next.t("general:Preview")}: + + + {this.renderImage(this.state.user.avatar, i18next.t("user:Upload a photo"), i18next.t("user:Set new profile picture"), "avatar", false)} ); @@ -536,12 +535,33 @@ class UserEditPage extends React.Component { {Setting.getLabel(i18next.t("user:ID card"), i18next.t("user:ID card - Tooltip"))} : - { + { this.updateUserField("idCard", e.target.value); }} /> ); + } else if (accountItem.name === "ID card info") { + return ( + + + {Setting.getLabel(i18next.t("user:ID card info"), i18next.t("user:ID card info - Tooltip"))} : + + + + + {i18next.t("general:Preview")}: + + { + this.state.idCardInfo.map((key, index) => { + const newKey = this.state.idCardKey[index]; + return this.renderImage(this.state.user.properties[newKey] || "", this.getIdCardType(key), this.getIdCardText(key), newKey, disabled); + }) + } + + + + ); } else if (accountItem.name === "Homepage") { return ( @@ -942,6 +962,25 @@ class UserEditPage extends React.Component { } } + renderImage(imgUrl, title, set, tag, disabled) { + return ( + + { + imgUrl ? + + {imgUrl} + + : + +
+
+
{`请上传${title}...`}
+ + } + organization.name === this.state.organizationName)} /> + + ); + } + renderUser() { return ( { const [visible, setVisible] = useState(false); const [confirmLoading, setConfirmLoading] = useState(false); const {title} = props; + const {setTitle} = props; + const {tag} = props; + const {disabled} = props; const {user} = props; const {buttonText} = props; const {organization} = props; @@ -59,8 +62,8 @@ export const CropperDivModal = (props) => { } // Setting.showMessage("success", "uploading..."); const extension = image.substring(image.indexOf("/") + 1, image.indexOf(";base64")); - const fullFilePath = `avatar/${user.owner}/${user.name}.${extension}`; - ResourceBackend.uploadResource(user.owner, user.name, "avatar", "CropperDivModal", fullFilePath, blob) + const fullFilePath = `${tag}/${user.owner}/${user.name}.${extension}`; + ResourceBackend.uploadResource(user.owner, user.name, tag, "CropperDivModal", fullFilePath, blob) .then((res) => { if (res.status === "ok") { window.location.href = window.location.pathname; @@ -139,19 +142,19 @@ export const CropperDivModal = (props) => { return (
- {i18next.t("user:Set new profile picture")}] + [] } > diff --git a/web/src/locales/de/data.json b/web/src/locales/de/data.json index 2b4f5ab2..fc41b3a0 100644 --- a/web/src/locales/de/data.json +++ b/web/src/locales/de/data.json @@ -904,8 +904,13 @@ "Homepage - Tooltip": "Homepage-URL des Benutzers", "ID card": "Ausweis", "ID card - Tooltip": "ID card - Tooltip", + "ID card back": "ID card back", + "ID card front": "ID card front", + "ID card info": "ID card info", + "ID card info - Tooltip": "ID card info - Tooltip", "ID card type": "ID card type", "ID card type - Tooltip": "ID card type - Tooltip", + "ID card with person": "ID card with person", "Input your email": "Geben Sie Ihre E-Mail-Adresse ein", "Input your phone number": "Geben Sie Ihre Telefonnummer ein", "Is admin": "Ist Admin", @@ -961,6 +966,9 @@ "Two passwords you typed do not match.": "Zwei von Ihnen eingegebene Passwörter stimmen nicht überein.", "Unlink": "Link aufheben", "Upload (.xlsx)": "Hochladen (.xlsx)", + "Upload ID card back picture": "Upload ID card back picture", + "Upload ID card front picture": "Upload ID card front picture", + "Upload ID card with person picture": "Upload ID card with person picture", "Upload a photo": "Lade ein Foto hoch", "Values": "Werte", "Verification code sent": "Bestätigungscode gesendet", diff --git a/web/src/locales/en/data.json b/web/src/locales/en/data.json index 8b116f5a..695cc6d0 100644 --- a/web/src/locales/en/data.json +++ b/web/src/locales/en/data.json @@ -570,8 +570,8 @@ "pricing": { "Copy pricing page URL": "Copy pricing page URL", "Edit Pricing": "Edit Pricing", - "Free": "Free", "Failed to get plans": "Failed to get plans", + "Free": "Free", "Getting started": "Getting started", "New Pricing": "New Pricing", "Trial duration": "Trial duration", @@ -904,8 +904,13 @@ "Homepage - Tooltip": "Homepage URL of the user", "ID card": "ID card", "ID card - Tooltip": "ID card - Tooltip", + "ID card back": "ID card back", + "ID card front": "ID card front", + "ID card info": "ID card info", + "ID card info - Tooltip": "ID card info - Tooltip", "ID card type": "ID card type", "ID card type - Tooltip": "ID card type - Tooltip", + "ID card with person": "ID card with person", "Input your email": "Input your email", "Input your phone number": "Input your phone number", "Is admin": "Is admin", @@ -961,6 +966,9 @@ "Two passwords you typed do not match.": "Two passwords you typed do not match.", "Unlink": "Unlink", "Upload (.xlsx)": "Upload (.xlsx)", + "Upload ID card back picture": "Upload ID card back picture", + "Upload ID card front picture": "Upload ID card front picture", + "Upload ID card with person picture": "Upload ID card with person picture", "Upload a photo": "Upload a photo", "Values": "Values", "Verification code sent": "Verification code sent", diff --git a/web/src/locales/es/data.json b/web/src/locales/es/data.json index b469cf15..2a746446 100644 --- a/web/src/locales/es/data.json +++ b/web/src/locales/es/data.json @@ -570,8 +570,8 @@ "pricing": { "Copy pricing page URL": "Copiar URL de la página de precios", "Edit Pricing": "Edit Pricing", - "Free": "Gratis", "Failed to get plans": "No se pudieron obtener los planes", + "Free": "Gratis", "Getting started": "Empezar", "New Pricing": "New Pricing", "Trial duration": "Duración del período de prueba", @@ -904,8 +904,13 @@ "Homepage - Tooltip": "URL de la página de inicio del usuario", "ID card": "Tarjeta de identificación", "ID card - Tooltip": "ID card - Tooltip", + "ID card back": "ID card back", + "ID card front": "ID card front", + "ID card info": "ID card info", + "ID card info - Tooltip": "ID card info - Tooltip", "ID card type": "ID card type", "ID card type - Tooltip": "ID card type - Tooltip", + "ID card with person": "ID card with person", "Input your email": "Introduce tu correo electrónico", "Input your phone number": "Ingrese su número de teléfono", "Is admin": "Es el administrador", @@ -961,6 +966,9 @@ "Two passwords you typed do not match.": "Dos contraseñas que has escrito no coinciden.", "Unlink": "Desvincular", "Upload (.xlsx)": "Subir (.xlsx)", + "Upload ID card back picture": "Upload ID card back picture", + "Upload ID card front picture": "Upload ID card front picture", + "Upload ID card with person picture": "Upload ID card with person picture", "Upload a photo": "Subir una foto", "Values": "Valores", "Verification code sent": "Código de verificación enviado", diff --git a/web/src/locales/fr/data.json b/web/src/locales/fr/data.json index dc2e05f4..4204444e 100644 --- a/web/src/locales/fr/data.json +++ b/web/src/locales/fr/data.json @@ -570,8 +570,8 @@ "pricing": { "Copy pricing page URL": "Copier l'URL de la page tarifs", "Edit Pricing": "Edit Pricing", - "Free": "Gratuit", "Failed to get plans": "Échec de l'obtention des plans", + "Free": "Gratuit", "Getting started": "Commencer", "New Pricing": "New Pricing", "Trial duration": "Durée de l'essai", @@ -904,8 +904,13 @@ "Homepage - Tooltip": "Adresse URL de la page d'accueil de l'utilisateur", "ID card": "carte d'identité", "ID card - Tooltip": "ID card - Tooltip", + "ID card back": "ID card back", + "ID card front": "ID card front", + "ID card info": "ID card info", + "ID card info - Tooltip": "ID card info - Tooltip", "ID card type": "ID card type", "ID card type - Tooltip": "ID card type - Tooltip", + "ID card with person": "ID card with person", "Input your email": "Entrez votre adresse e-mail", "Input your phone number": "Saisissez votre numéro de téléphone", "Is admin": "Est l'administrateur", @@ -961,6 +966,9 @@ "Two passwords you typed do not match.": "Deux mots de passe que vous avez tapés ne correspondent pas.", "Unlink": "Détacher", "Upload (.xlsx)": "Télécharger (.xlsx)", + "Upload ID card back picture": "Upload ID card back picture", + "Upload ID card front picture": "Upload ID card front picture", + "Upload ID card with person picture": "Upload ID card with person picture", "Upload a photo": "Télécharger une photo", "Values": "Valeurs", "Verification code sent": "Code de vérification envoyé", diff --git a/web/src/locales/id/data.json b/web/src/locales/id/data.json index d2d04fc8..16cc925b 100644 --- a/web/src/locales/id/data.json +++ b/web/src/locales/id/data.json @@ -570,8 +570,8 @@ "pricing": { "Copy pricing page URL": "Salin URL halaman harga", "Edit Pricing": "Edit Pricing", - "Free": "Gratis", "Failed to get plans": "Gagal mendapatkan rencana", + "Free": "Gratis", "Getting started": "Mulai", "New Pricing": "New Pricing", "Trial duration": "Durasi percobaan", @@ -904,8 +904,13 @@ "Homepage - Tooltip": "URL halaman depan pengguna", "ID card": "Kartu identitas", "ID card - Tooltip": "ID card - Tooltip", + "ID card back": "ID card back", + "ID card front": "ID card front", + "ID card info": "ID card info", + "ID card info - Tooltip": "ID card info - Tooltip", "ID card type": "ID card type", "ID card type - Tooltip": "ID card type - Tooltip", + "ID card with person": "ID card with person", "Input your email": "Masukkan alamat email Anda", "Input your phone number": "Masukkan nomor telepon Anda", "Is admin": "Apakah admin?", @@ -961,6 +966,9 @@ "Two passwords you typed do not match.": "Dua password yang Anda ketikkan tidak cocok.", "Unlink": "Membatalkan Tautan", "Upload (.xlsx)": "Unggah (.xlsx)", + "Upload ID card back picture": "Upload ID card back picture", + "Upload ID card front picture": "Upload ID card front picture", + "Upload ID card with person picture": "Upload ID card with person picture", "Upload a photo": "Unggah foto", "Values": "Nilai-nilai", "Verification code sent": "Kode verifikasi telah dikirim", diff --git a/web/src/locales/ja/data.json b/web/src/locales/ja/data.json index 4986f3eb..053909a0 100644 --- a/web/src/locales/ja/data.json +++ b/web/src/locales/ja/data.json @@ -570,8 +570,8 @@ "pricing": { "Copy pricing page URL": "価格ページのURLをコピー", "Edit Pricing": "Edit Pricing", - "Free": "無料", "Failed to get plans": "計画の取得に失敗しました", + "Free": "無料", "Getting started": "はじめる", "New Pricing": "New Pricing", "Trial duration": "トライアル期間の長さ", @@ -904,8 +904,13 @@ "Homepage - Tooltip": "ユーザーのホームページのURL", "ID card": "IDカード", "ID card - Tooltip": "ID card - Tooltip", + "ID card back": "ID card back", + "ID card front": "ID card front", + "ID card info": "ID card info", + "ID card info - Tooltip": "ID card info - Tooltip", "ID card type": "ID card type", "ID card type - Tooltip": "ID card type - Tooltip", + "ID card with person": "ID card with person", "Input your email": "あなたのメールアドレスを入力してください", "Input your phone number": "電話番号を入力してください", "Is admin": "管理者ですか?", @@ -961,6 +966,9 @@ "Two passwords you typed do not match.": "2つのパスワードが一致しません。", "Unlink": "アンリンク", "Upload (.xlsx)": "アップロード(.xlsx)", + "Upload ID card back picture": "Upload ID card back picture", + "Upload ID card front picture": "Upload ID card front picture", + "Upload ID card with person picture": "Upload ID card with person picture", "Upload a photo": "写真をアップロードしてください", "Values": "価値観", "Verification code sent": "確認コードを送信しました", diff --git a/web/src/locales/ko/data.json b/web/src/locales/ko/data.json index 6d1f54b8..22918f34 100644 --- a/web/src/locales/ko/data.json +++ b/web/src/locales/ko/data.json @@ -570,8 +570,8 @@ "pricing": { "Copy pricing page URL": "가격 페이지 URL 복사", "Edit Pricing": "Edit Pricing", - "Free": "무료", "Failed to get plans": "계획을 가져오지 못했습니다.", + "Free": "무료", "Getting started": "시작하기", "New Pricing": "New Pricing", "Trial duration": "체험 기간", @@ -904,8 +904,13 @@ "Homepage - Tooltip": "사용자의 홈페이지 URL", "ID card": "ID 카드", "ID card - Tooltip": "ID card - Tooltip", + "ID card back": "ID card back", + "ID card front": "ID card front", + "ID card info": "ID card info", + "ID card info - Tooltip": "ID card info - Tooltip", "ID card type": "ID card type", "ID card type - Tooltip": "ID card type - Tooltip", + "ID card with person": "ID card with person", "Input your email": "이메일을 입력하세요", "Input your phone number": "전화번호를 입력하세요", "Is admin": "어드민인가요?", @@ -961,6 +966,9 @@ "Two passwords you typed do not match.": "두 개의 비밀번호가 일치하지 않습니다.", "Unlink": "연결 해제하기", "Upload (.xlsx)": "업로드 (.xlsx)", + "Upload ID card back picture": "Upload ID card back picture", + "Upload ID card front picture": "Upload ID card front picture", + "Upload ID card with person picture": "Upload ID card with person picture", "Upload a photo": "사진을 업로드하세요", "Values": "가치들", "Verification code sent": "인증 코드가 전송되었습니다", diff --git a/web/src/locales/pt/data.json b/web/src/locales/pt/data.json index b40cff9e..59c35cca 100644 --- a/web/src/locales/pt/data.json +++ b/web/src/locales/pt/data.json @@ -570,8 +570,8 @@ "pricing": { "Copy pricing page URL": "Sao chép URL trang bảng giá", "Edit Pricing": "Edit Pricing", - "Free": "Miễn phí", "Failed to get plans": "Falha ao obter planos", + "Free": "Miễn phí", "Getting started": "Bắt đầu", "New Pricing": "New Pricing", "Trial duration": "Thời gian thử nghiệm", @@ -904,8 +904,13 @@ "Homepage - Tooltip": "URL da página inicial do usuário", "ID card": "Cartão de identidade", "ID card - Tooltip": "Cartão de identidade - Tooltip", + "ID card back": "ID card back", + "ID card front": "ID card front", + "ID card info": "ID card info", + "ID card info - Tooltip": "ID card info - Tooltip", "ID card type": "Tipo de cartão de identidade", "ID card type - Tooltip": "Tipo de cartão de identidade - Tooltip", + "ID card with person": "ID card with person", "Input your email": "Digite seu e-mail", "Input your phone number": "Digite seu número de telefone", "Is admin": "É administrador", @@ -961,6 +966,9 @@ "Two passwords you typed do not match.": "As duas senhas digitadas não coincidem.", "Unlink": "Desvincular", "Upload (.xlsx)": "Enviar (.xlsx)", + "Upload ID card back picture": "Upload ID card back picture", + "Upload ID card front picture": "Upload ID card front picture", + "Upload ID card with person picture": "Upload ID card with person picture", "Upload a photo": "Enviar uma foto", "Values": "Valores", "Verification code sent": "Código de verificação enviado", diff --git a/web/src/locales/ru/data.json b/web/src/locales/ru/data.json index edbb8044..1ff93d23 100644 --- a/web/src/locales/ru/data.json +++ b/web/src/locales/ru/data.json @@ -570,8 +570,8 @@ "pricing": { "Copy pricing page URL": "Скопировать URL прайс-листа", "Edit Pricing": "Edit Pricing", - "Free": "Бесплатно", "Failed to get plans": "Не удалось получить планы", + "Free": "Бесплатно", "Getting started": "Выьрать план", "New Pricing": "New Pricing", "Trial duration": "Продолжительность пробного периода", @@ -904,8 +904,13 @@ "Homepage - Tooltip": "URL домашней страницы пользователя", "ID card": "ID-карта", "ID card - Tooltip": "ID card - Tooltip", + "ID card back": "ID card back", + "ID card front": "ID card front", + "ID card info": "ID card info", + "ID card info - Tooltip": "ID card info - Tooltip", "ID card type": "ID card type", "ID card type - Tooltip": "ID card type - Tooltip", + "ID card with person": "ID card with person", "Input your email": "Введите свой адрес электронной почты", "Input your phone number": "Введите ваш номер телефона", "Is admin": "Это администратор", @@ -961,6 +966,9 @@ "Two passwords you typed do not match.": "Два введенных вами пароля не совпадают.", "Unlink": "Отсоединить", "Upload (.xlsx)": "Загрузить (.xlsx)", + "Upload ID card back picture": "Upload ID card back picture", + "Upload ID card front picture": "Upload ID card front picture", + "Upload ID card with person picture": "Upload ID card with person picture", "Upload a photo": "Загрузить фото", "Values": "Значения", "Verification code sent": "Код подтверждения отправлен", diff --git a/web/src/locales/vi/data.json b/web/src/locales/vi/data.json index e92699f0..055c94dd 100644 --- a/web/src/locales/vi/data.json +++ b/web/src/locales/vi/data.json @@ -570,8 +570,8 @@ "pricing": { "Copy pricing page URL": "Sao chép URL trang bảng giá", "Edit Pricing": "Edit Pricing", - "Free": "Miễn phí", "Failed to get plans": "Không thể lấy được các kế hoạch", + "Free": "Miễn phí", "Getting started": "Bắt đầu", "New Pricing": "New Pricing", "Trial duration": "Thời gian thử nghiệm", @@ -904,8 +904,13 @@ "Homepage - Tooltip": "Địa chỉ URL của trang chủ của người dùng", "ID card": "Thẻ căn cước dân sự", "ID card - Tooltip": "ID card - Tooltip", + "ID card back": "ID card back", + "ID card front": "ID card front", + "ID card info": "ID card info", + "ID card info - Tooltip": "ID card info - Tooltip", "ID card type": "ID card type", "ID card type - Tooltip": "ID card type - Tooltip", + "ID card with person": "ID card with person", "Input your email": "Nhập địa chỉ email của bạn", "Input your phone number": "Nhập số điện thoại của bạn", "Is admin": "Là quản trị viên", @@ -961,6 +966,9 @@ "Two passwords you typed do not match.": "Hai mật khẩu mà bạn đã nhập không khớp.", "Unlink": "Hủy liên kết", "Upload (.xlsx)": "Tải lên (.xlsx)", + "Upload ID card back picture": "Upload ID card back picture", + "Upload ID card front picture": "Upload ID card front picture", + "Upload ID card with person picture": "Upload ID card with person picture", "Upload a photo": "Tải lên một bức ảnh", "Values": "Giá trị", "Verification code sent": "Mã xác minh đã được gửi", diff --git a/web/src/locales/zh/data.json b/web/src/locales/zh/data.json index 5c57c95d..7b404e2d 100644 --- a/web/src/locales/zh/data.json +++ b/web/src/locales/zh/data.json @@ -902,8 +902,13 @@ "Homepage - Tooltip": "个人主页链接", "ID card": "身份证号", "ID card - Tooltip": "身份证号 - Tooltip", + "ID card back": "身份证反面", + "ID card front": "身份证正面", + "ID card info": "身份证照片", + "ID card info - Tooltip": "身份证照片用于进行用户身份验证,验证成功后如要修改请联系管理员", "ID card type": "身份证类型", "ID card type - Tooltip": "身份证类型 - Tooltip", + "ID card with person": "手持身份证", "Input your email": "请输入邮箱", "Input your phone number": "输入手机号", "Is admin": "是组织管理员", @@ -959,6 +964,9 @@ "Two passwords you typed do not match.": "两次输入的密码不匹配。", "Unlink": "解绑", "Upload (.xlsx)": "上传(.xlsx)", + "Upload ID card back picture": "上传身份证反面照片", + "Upload ID card front picture": "上传身份证正面照片", + "Upload ID card with person picture": "上传手持身份证照片", "Upload a photo": "上传头像", "Values": "值", "Verification code sent": "验证码已发送",