From 04f0458b5cdcd1eb4f03e262d59a593f76248ea3 Mon Sep 17 00:00:00 2001 From: HGZ-20 Date: Sat, 16 Mar 2024 22:52:57 +0800 Subject: [PATCH] feat: improve handleCameraError() and camera call logic (#2809) add i18n for face recognition --- i18n/locales/ar/data.json | 3 + i18n/locales/de/data.json | 3 + i18n/locales/en/data.json | 3 + i18n/locales/es/data.json | 3 + i18n/locales/fa/data.json | 3 + i18n/locales/fi/data.json | 3 + i18n/locales/fr/data.json | 3 + i18n/locales/he/data.json | 3 + i18n/locales/id/data.json | 3 + i18n/locales/it/data.json | 3 + i18n/locales/ja/data.json | 3 + i18n/locales/kk/data.json | 3 + i18n/locales/ko/data.json | 3 + i18n/locales/ms/data.json | 3 + i18n/locales/nl/data.json | 3 + i18n/locales/pl/data.json | 3 + i18n/locales/pt/data.json | 3 + i18n/locales/ru/data.json | 3 + i18n/locales/sv/data.json | 3 + i18n/locales/tr/data.json | 3 + i18n/locales/uk/data.json | 3 + i18n/locales/vi/data.json | 3 + i18n/locales/zh/data.json | 3 + web/package.json | 3 +- web/src/common/modal/FaceRecognitionModal.js | 80 +++++++++++++++----- web/src/locales/ar/data.json | 13 ++++ web/src/locales/de/data.json | 13 ++++ web/src/locales/en/data.json | 13 ++++ web/src/locales/es/data.json | 13 ++++ web/src/locales/fa/data.json | 13 ++++ web/src/locales/fi/data.json | 13 ++++ web/src/locales/fr/data.json | 13 ++++ web/src/locales/he/data.json | 13 ++++ web/src/locales/id/data.json | 13 ++++ web/src/locales/it/data.json | 13 ++++ web/src/locales/ja/data.json | 13 ++++ web/src/locales/kk/data.json | 13 ++++ web/src/locales/ko/data.json | 13 ++++ web/src/locales/ms/data.json | 13 ++++ web/src/locales/nl/data.json | 13 ++++ web/src/locales/pl/data.json | 13 ++++ web/src/locales/pt/data.json | 13 ++++ web/src/locales/ru/data.json | 13 ++++ web/src/locales/sv/data.json | 13 ++++ web/src/locales/tr/data.json | 13 ++++ web/src/locales/uk/data.json | 13 ++++ web/src/locales/vi/data.json | 13 ++++ web/src/locales/zh/data.json | 13 ++++ web/yarn.lock | 5 -- 49 files changed, 429 insertions(+), 27 deletions(-) diff --git a/i18n/locales/ar/data.json b/i18n/locales/ar/data.json index 5a6a549e..8504a621 100644 --- a/i18n/locales/ar/data.json +++ b/i18n/locales/ar/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email cannot be empty", "Email is invalid": "Email is invalid", "Empty username.": "Empty username.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "FirstName cannot be blank", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/de/data.json b/i18n/locales/de/data.json index e1bd0ce3..311d9ace 100644 --- a/i18n/locales/de/data.json +++ b/i18n/locales/de/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "Die Anmeldeart \"Anmeldung mit Passwort\" ist für die Anwendung nicht aktiviert", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "Der Anbieter: %s ist nicht für die Anwendung aktiviert", @@ -38,6 +39,8 @@ "Email cannot be empty": "E-Mail darf nicht leer sein", "Email is invalid": "E-Mail ist ungültig", "Empty username.": "Leerer Benutzername.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "Vorname darf nicht leer sein", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/en/data.json b/i18n/locales/en/data.json index 5a6a549e..8504a621 100644 --- a/i18n/locales/en/data.json +++ b/i18n/locales/en/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email cannot be empty", "Email is invalid": "Email is invalid", "Empty username.": "Empty username.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "FirstName cannot be blank", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/es/data.json b/i18n/locales/es/data.json index 163d375b..f656cd13 100644 --- a/i18n/locales/es/data.json +++ b/i18n/locales/es/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "El método de inicio de sesión: inicio de sesión con contraseña no está habilitado para la aplicación", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "El proveedor: %s no está habilitado para la aplicación", @@ -38,6 +39,8 @@ "Email cannot be empty": "El correo electrónico no puede estar vacío", "Email is invalid": "El correo electrónico no es válido", "Empty username.": "Nombre de usuario vacío.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "El nombre no puede estar en blanco", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/fa/data.json b/i18n/locales/fa/data.json index 5a6a549e..8504a621 100644 --- a/i18n/locales/fa/data.json +++ b/i18n/locales/fa/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email cannot be empty", "Email is invalid": "Email is invalid", "Empty username.": "Empty username.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "FirstName cannot be blank", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/fi/data.json b/i18n/locales/fi/data.json index 5a6a549e..8504a621 100644 --- a/i18n/locales/fi/data.json +++ b/i18n/locales/fi/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email cannot be empty", "Email is invalid": "Email is invalid", "Empty username.": "Empty username.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "FirstName cannot be blank", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/fr/data.json b/i18n/locales/fr/data.json index bc268a91..ed839d68 100644 --- a/i18n/locales/fr/data.json +++ b/i18n/locales/fr/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "La méthode de connexion : connexion avec mot de passe n'est pas activée pour l'application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "Le fournisseur :%s n'est pas activé pour l'application", @@ -38,6 +39,8 @@ "Email cannot be empty": "L'e-mail ne peut pas être vide", "Email is invalid": "L'adresse e-mail est invalide", "Empty username.": "Nom d'utilisateur vide.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "Le prénom ne peut pas être laissé vide", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/he/data.json b/i18n/locales/he/data.json index 5a6a549e..8504a621 100644 --- a/i18n/locales/he/data.json +++ b/i18n/locales/he/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email cannot be empty", "Email is invalid": "Email is invalid", "Empty username.": "Empty username.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "FirstName cannot be blank", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/id/data.json b/i18n/locales/id/data.json index beed1973..ef407e18 100644 --- a/i18n/locales/id/data.json +++ b/i18n/locales/id/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "Metode login: login dengan kata sandi tidak diaktifkan untuk aplikasi tersebut", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "Penyedia: %s tidak diaktifkan untuk aplikasi ini", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email tidak boleh kosong", "Email is invalid": "Email tidak valid", "Empty username.": "Nama pengguna kosong.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "Nama depan tidak boleh kosong", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/it/data.json b/i18n/locales/it/data.json index 5a6a549e..8504a621 100644 --- a/i18n/locales/it/data.json +++ b/i18n/locales/it/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email cannot be empty", "Email is invalid": "Email is invalid", "Empty username.": "Empty username.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "FirstName cannot be blank", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/ja/data.json b/i18n/locales/ja/data.json index cc6fc2d8..1f769b1c 100644 --- a/i18n/locales/ja/data.json +++ b/i18n/locales/ja/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "ログイン方法:パスワードでのログインはアプリケーションで有効になっていません", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "プロバイダー:%sはアプリケーションでは有効化されていません", @@ -38,6 +39,8 @@ "Email cannot be empty": "メールが空白にできません", "Email is invalid": "電子メールは無効です", "Empty username.": "空のユーザー名。", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "ファーストネームは空白にできません", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/kk/data.json b/i18n/locales/kk/data.json index 5a6a549e..8504a621 100644 --- a/i18n/locales/kk/data.json +++ b/i18n/locales/kk/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email cannot be empty", "Email is invalid": "Email is invalid", "Empty username.": "Empty username.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "FirstName cannot be blank", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/ko/data.json b/i18n/locales/ko/data.json index c00fbf08..b39979df 100644 --- a/i18n/locales/ko/data.json +++ b/i18n/locales/ko/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "어플리케이션에서는 암호를 사용한 로그인 방법이 활성화되어 있지 않습니다", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "제공자 %s은(는) 응용 프로그램에서 활성화되어 있지 않습니다", @@ -38,6 +39,8 @@ "Email cannot be empty": "이메일은 비어 있을 수 없습니다", "Email is invalid": "이메일이 유효하지 않습니다", "Empty username.": "빈 사용자 이름.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "이름은 공백일 수 없습니다", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/ms/data.json b/i18n/locales/ms/data.json index 5a6a549e..8504a621 100644 --- a/i18n/locales/ms/data.json +++ b/i18n/locales/ms/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email cannot be empty", "Email is invalid": "Email is invalid", "Empty username.": "Empty username.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "FirstName cannot be blank", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/nl/data.json b/i18n/locales/nl/data.json index 5a6a549e..8504a621 100644 --- a/i18n/locales/nl/data.json +++ b/i18n/locales/nl/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email cannot be empty", "Email is invalid": "Email is invalid", "Empty username.": "Empty username.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "FirstName cannot be blank", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/pl/data.json b/i18n/locales/pl/data.json index 5a6a549e..8504a621 100644 --- a/i18n/locales/pl/data.json +++ b/i18n/locales/pl/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email cannot be empty", "Email is invalid": "Email is invalid", "Empty username.": "Empty username.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "FirstName cannot be blank", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/pt/data.json b/i18n/locales/pt/data.json index c0946681..7d444c61 100644 --- a/i18n/locales/pt/data.json +++ b/i18n/locales/pt/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email cannot be empty", "Email is invalid": "Email is invalid", "Empty username.": "Empty username.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "FirstName cannot be blank", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/ru/data.json b/i18n/locales/ru/data.json index 53c919aa..0a050b10 100644 --- a/i18n/locales/ru/data.json +++ b/i18n/locales/ru/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "Метод входа: вход с паролем не включен для приложения", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "Провайдер: %s не включен для приложения", @@ -38,6 +39,8 @@ "Email cannot be empty": "Электронная почта не может быть пустой", "Email is invalid": "Адрес электронной почты недействительный", "Empty username.": "Пустое имя пользователя.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "Имя не может быть пустым", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/sv/data.json b/i18n/locales/sv/data.json index 5a6a549e..8504a621 100644 --- a/i18n/locales/sv/data.json +++ b/i18n/locales/sv/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email cannot be empty", "Email is invalid": "Email is invalid", "Empty username.": "Empty username.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "FirstName cannot be blank", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/tr/data.json b/i18n/locales/tr/data.json index bcbcd50e..5ab85c0b 100644 --- a/i18n/locales/tr/data.json +++ b/i18n/locales/tr/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email cannot be empty", "Email is invalid": "Email is invalid", "Empty username.": "Empty username.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "FirstName cannot be blank", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/uk/data.json b/i18n/locales/uk/data.json index 5a6a549e..8504a621 100644 --- a/i18n/locales/uk/data.json +++ b/i18n/locales/uk/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email cannot be empty", "Email is invalid": "Email is invalid", "Empty username.": "Empty username.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "FirstName cannot be blank", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/vi/data.json b/i18n/locales/vi/data.json index 46d15aa1..7d7cb5f8 100644 --- a/i18n/locales/vi/data.json +++ b/i18n/locales/vi/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "The login method: login with LDAP is not enabled for the application", "The login method: login with SMS is not enabled for the application": "The login method: login with SMS is not enabled for the application", "The login method: login with email is not enabled for the application": "The login method: login with email is not enabled for the application", + "The login method: login with face is not enabled for the application": "The login method: login with face is not enabled for the application", "The login method: login with password is not enabled for the application": "Phương thức đăng nhập: đăng nhập bằng mật khẩu không được kích hoạt cho ứng dụng", "The organization: %s does not exist": "The organization: %s does not exist", "The provider: %s is not enabled for the application": "Nhà cung cấp: %s không được kích hoạt cho ứng dụng", @@ -38,6 +39,8 @@ "Email cannot be empty": "Email không thể để trống", "Email is invalid": "Địa chỉ email không hợp lệ", "Empty username.": "Tên đăng nhập trống.", + "Face data does not exist, cannot log in": "Face data does not exist, cannot log in", + "Face data mismatch": "Face data mismatch", "FirstName cannot be blank": "Tên không được để trống", "Invitation code cannot be blank": "Invitation code cannot be blank", "Invitation code exhausted": "Invitation code exhausted", diff --git a/i18n/locales/zh/data.json b/i18n/locales/zh/data.json index fa9328b3..90576ce2 100644 --- a/i18n/locales/zh/data.json +++ b/i18n/locales/zh/data.json @@ -18,6 +18,7 @@ "The login method: login with LDAP is not enabled for the application": "该应用禁止采用LDAP登录方式", "The login method: login with SMS is not enabled for the application": "该应用禁止采用短信登录方式", "The login method: login with email is not enabled for the application": "该应用禁止采用邮箱登录方式", + "The login method: login with face is not enabled for the application": "该应用禁止采用人脸登录", "The login method: login with password is not enabled for the application": "该应用禁止采用密码登录方式", "The organization: %s does not exist": "组织: %s 不存在", "The provider: %s is not enabled for the application": "该应用的提供商: %s未被启用", @@ -38,6 +39,8 @@ "Email cannot be empty": "邮箱不可为空", "Email is invalid": "无效邮箱", "Empty username.": "用户名不可为空", + "Face data does not exist, cannot log in": "未录入人脸数据,无法登录", + "Face data mismatch": "人脸不匹配", "FirstName cannot be blank": "名不可以为空", "Invitation code cannot be blank": "邀请码不能为空", "Invitation code exhausted": "邀请码使用次数已耗尽", diff --git a/web/package.json b/web/package.json index a9f168d7..ef14fb37 100644 --- a/web/package.json +++ b/web/package.json @@ -51,8 +51,7 @@ "react-metamask-avatar": "^1.2.1", "react-router-dom": "^5.3.3", "react-scripts": "5.0.1", - "react-social-login-buttons": "^3.4.0", - "react-webcam": "^7.2.0" + "react-social-login-buttons": "^3.4.0" }, "scripts": { "start": "cross-env PORT=7001 craco start", diff --git a/web/src/common/modal/FaceRecognitionModal.js b/web/src/common/modal/FaceRecognitionModal.js index b611e0ab..00fd2af8 100644 --- a/web/src/common/modal/FaceRecognitionModal.js +++ b/web/src/common/modal/FaceRecognitionModal.js @@ -14,17 +14,18 @@ import * as faceapi from "face-api.js"; import React, {useState} from "react"; -import Webcam from "react-webcam"; import {Button, Modal, Progress, Spin, message} from "antd"; import i18next from "i18next"; const FaceRecognitionModal = (props) => { const {visible, onOk, onCancel} = props; const [modelsLoaded, setModelsLoaded] = React.useState(false); + const [isCameraCaptured, setIsCameraCaptured] = useState(false); - const webcamRef = React.useRef(); + const videoRef = React.useRef(); const canvasRef = React.useRef(); const detection = React.useRef(null); + const mediaStreamRef = React.useRef(null); const [percent, setPercent] = useState(0); React.useEffect(() => { @@ -51,26 +52,58 @@ const FaceRecognitionModal = (props) => { React.useEffect(() => { if (visible) { setPercent(0); - if (modelsLoaded && webcamRef.current?.video) { - handleStreamVideo(null); + if (modelsLoaded) { + navigator.mediaDevices + .getUserMedia({video: {facingMode: "user"}}) + .then((stream) => { + mediaStreamRef.current = stream; + setIsCameraCaptured(true); + }).catch((error) => { + handleCameraError(error); + }); } } else { clearInterval(detection.current); detection.current = null; + setIsCameraCaptured(false); } return () => { clearInterval(detection.current); detection.current = null; + setIsCameraCaptured(false); }; - }, [visible]); + }, [visible, modelsLoaded]); - const handleStreamVideo = (e) => { + React.useEffect(() => { + if (isCameraCaptured) { + let count = 0; + const interval = setInterval(() => { + count++; + if (videoRef.current) { + videoRef.current.srcObject = mediaStreamRef.current; + videoRef.current.play(); + clearInterval(interval); + } + if (count >= 30) { + clearInterval(interval); + onCancel(); + } + }, 100); + } else { + mediaStreamRef.current?.getTracks().forEach(track => track.stop()); + if (videoRef.current) { + videoRef.current.srcObject = null; + } + } + }, [isCameraCaptured]); + + const handleStreamVideo = () => { let count = 0; let goodCount = 0; if (!detection.current) { detection.current = setInterval(async() => { - if (modelsLoaded && webcamRef.current?.video && visible) { - const faces = await faceapi.detectAllFaces(webcamRef.current.video, new faceapi.TinyFaceDetectorOptions()).withFaceLandmarks().withFaceDescriptors(); + if (modelsLoaded && videoRef.current && visible) { + const faces = await faceapi.detectAllFaces(videoRef.current, new faceapi.TinyFaceDetectorOptions()).withFaceLandmarks().withFaceDescriptors(); count++; if (count % 50 === 0) { @@ -99,11 +132,19 @@ const FaceRecognitionModal = (props) => { }; const handleCameraError = (error) => { - // https://github.com/mozmorris/react-webcam/issues/272 - if (error.message.includes("device not found")) { - message.error(i18next.t("login:You need to have a camera device to login with Face ID")); - } else { - message.error(error.message); + onCancel(); + if (error instanceof DOMException) { + if (error.name === "NotFoundError" || error.name === "DevicesNotFoundError") { + message.error(i18next.t("login:Please ensure that you have a camera device for facial recognition")); + } else if (error.name === "NotAllowedError" || error.name === "PermissionDeniedError") { + message.error(i18next.t("login:Please provide permission to access the camera")); + } else if (error.name === "NotReadableError" || error.name === "TrackStartError") { + message.error(i18next.t("login:The camera is currently in use by another webpage")); + } else if (error.name === "TypeError") { + message.error(i18next.t("login:Please load the webpage using HTTPS, otherwise the camera cannot be accessed")); + } else { + message.error(error.message); + } } }; @@ -112,7 +153,8 @@ const FaceRecognitionModal = (props) => { { { modelsLoaded ?
- { width: "220px", objectFit: "cover", }} - > + >