mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-12 13:10:05 +00:00
chore: reset two-factor authentication after changing admin credentials
This commit is contained in:
parent
bd80073402
commit
5546c27fea
16 changed files with 71 additions and 20 deletions
|
@ -15,8 +15,8 @@
|
|||
<p>{{ i18n "pages.settings.security.twoFactorModalSecondStep" }}</p>
|
||||
<a-input v-model.trim="twoFactorModal.enteredCode" :style="{ width: '100%' }"></a-input>
|
||||
</template>
|
||||
<template v-if="twoFactorModal.type === 'remove'">
|
||||
<p>{{ i18n "pages.settings.security.twoFactorModalRemoveStep" }}</p>
|
||||
<template v-if="twoFactorModal.type === 'confirm'">
|
||||
<p>[[ twoFactorModal.description ]]</p>
|
||||
<a-input v-model.trim="twoFactorModal.enteredCode" :style="{ width: '100%' }"></a-input>
|
||||
</template>
|
||||
<template slot="footer">
|
||||
|
@ -32,6 +32,7 @@
|
|||
<script>
|
||||
const twoFactorModal = {
|
||||
title: '',
|
||||
description: '',
|
||||
fileName: '',
|
||||
token: '',
|
||||
enteredCode: '',
|
||||
|
@ -45,17 +46,6 @@
|
|||
ObjectUtil.execute(twoFactorModal.confirm, true)
|
||||
|
||||
twoFactorModal.close()
|
||||
|
||||
switch (twoFactorModal.type) {
|
||||
case 'set':
|
||||
Vue.prototype.$message['success']('{{ i18n "pages.settings.security.twoFactorModalSetSuccess" }}')
|
||||
break;
|
||||
case 'remove':
|
||||
Vue.prototype.$message['success']('{{ i18n "pages.settings.security.twoFactorModalDeleteSuccess" }}')
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Vue.prototype.$message['error']('{{ i18n "pages.settings.security.twoFactorModalError" }}')
|
||||
}
|
||||
|
@ -67,11 +57,13 @@
|
|||
},
|
||||
show: function ({
|
||||
title = '',
|
||||
description = '',
|
||||
token = '',
|
||||
type = 'set',
|
||||
confirm = (success) => { }
|
||||
}) {
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.token = token;
|
||||
this.visible = true;
|
||||
this.confirm = confirm;
|
||||
|
|
|
@ -270,12 +270,30 @@
|
|||
}
|
||||
},
|
||||
async updateUser() {
|
||||
this.loading(true);
|
||||
const msg = await HttpUtil.post("/panel/setting/updateUser", this.user);
|
||||
this.loading(false);
|
||||
if (msg.success) {
|
||||
this.user = {};
|
||||
window.location.replace(basePath + "logout");
|
||||
const sendUpdateUserRequest = async () => {
|
||||
this.loading(true);
|
||||
const msg = await HttpUtil.post("/panel/setting/updateUser", this.user);
|
||||
this.loading(false);
|
||||
if (msg.success) {
|
||||
this.user = {};
|
||||
window.location.replace(basePath + "logout");
|
||||
}
|
||||
}
|
||||
|
||||
if (this.allSetting.twoFactorEnable) {
|
||||
twoFactorModal.show({
|
||||
title: '{{ i18n "pages.settings.security.twoFactorModalChangeCredentialsTitle" }}',
|
||||
description: '{{ i18n "pages.settings.security.twoFactorModalChangeCredentialsStep" }}',
|
||||
token: this.allSetting.twoFactorToken,
|
||||
type: 'confirm',
|
||||
confirm: (success) => {
|
||||
if (success) {
|
||||
sendUpdateUserRequest();
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
sendUpdateUserRequest();
|
||||
}
|
||||
},
|
||||
async restartPanel() {
|
||||
|
@ -313,6 +331,8 @@
|
|||
type: 'set',
|
||||
confirm: (success) => {
|
||||
if (success) {
|
||||
Vue.prototype.$message['success']('{{ i18n "pages.settings.security.twoFactorModalSetSuccess" }}')
|
||||
|
||||
this.allSetting.twoFactorToken = newTwoFactorToken
|
||||
}
|
||||
|
||||
|
@ -322,10 +342,13 @@
|
|||
} else {
|
||||
twoFactorModal.show({
|
||||
title: '{{ i18n "pages.settings.security.twoFactorModalDeleteTitle" }}',
|
||||
description: '{{ i18n "pages.settings.security.twoFactorModalRemoveStep" }}',
|
||||
token: this.allSetting.twoFactorToken,
|
||||
type: 'remove',
|
||||
type: 'confirm',
|
||||
confirm: (success) => {
|
||||
if (success) {
|
||||
Vue.prototype.$message['success']('{{ i18n "pages.settings.security.twoFactorModalDeleteSuccess" }}')
|
||||
|
||||
this.allSetting.twoFactorEnable = false
|
||||
this.allSetting.twoFactorToken = ""
|
||||
}
|
||||
|
|
|
@ -79,6 +79,16 @@ func (s *UserService) UpdateUser(id int, username string, password string) error
|
|||
return err
|
||||
}
|
||||
|
||||
twoFactorEnable, err := s.settingService.GetTwoFactorEnable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if twoFactorEnable {
|
||||
s.settingService.SetTwoFactorEnable(false)
|
||||
s.settingService.SetTwoFactorToken("")
|
||||
}
|
||||
|
||||
return db.Model(model.User{}).
|
||||
Where("id = ?", id).
|
||||
Updates(map[string]any{"username": username, "password": hashedPassword}).
|
||||
|
|
|
@ -539,6 +539,8 @@
|
|||
"twoFactorModalFirstStep" = "1. امسح رمز QR هذا في تطبيق المصادقة أو انسخ الرمز الموجود بجانب رمز QR والصقه في التطبيق"
|
||||
"twoFactorModalSecondStep" = "2. أدخل الرمز من التطبيق"
|
||||
"twoFactorModalRemoveStep" = "أدخل الرمز من التطبيق لإزالة المصادقة الثنائية."
|
||||
"twoFactorModalChangeCredentialsTitle" = "تغيير بيانات الاعتماد"
|
||||
"twoFactorModalChangeCredentialsStep" = "أدخل الرمز من التطبيق لتغيير بيانات اعتماد المسؤول."
|
||||
"twoFactorModalSetSuccess" = "تم إنشاء المصادقة الثنائية بنجاح"
|
||||
"twoFactorModalDeleteSuccess" = "تم حذف المصادقة الثنائية بنجاح"
|
||||
"twoFactorModalError" = "رمز خاطئ"
|
||||
|
|
|
@ -538,6 +538,8 @@
|
|||
"twoFactorModalFirstStep" = "1. Scan this QR code in the app for authentication or copy the token near the QR code and paste it into the app"
|
||||
"twoFactorModalSecondStep" = "2. Enter the code from the app"
|
||||
"twoFactorModalRemoveStep" = "Enter the code from the application to remove two-factor authentication."
|
||||
"twoFactorModalChangeCredentialsTitle" = "Change credentials"
|
||||
"twoFactorModalChangeCredentialsStep" = "Enter the code from the application to change administrator credentials."
|
||||
"twoFactorModalSetSuccess" = "Two-factor authentication has been successfully established"
|
||||
"twoFactorModalDeleteSuccess" = "Two-factor authentication has been successfully deleted"
|
||||
"twoFactorModalError" = "Wrong code"
|
||||
|
|
|
@ -541,6 +541,8 @@
|
|||
"twoFactorModalFirstStep" = "1. Escanea este código QR en la aplicación de autenticación o copia el token cerca del código QR y pégalo en la aplicación"
|
||||
"twoFactorModalSecondStep" = "2. Ingresa el código de la aplicación"
|
||||
"twoFactorModalRemoveStep" = "Ingresa el código de la aplicación para eliminar la autenticación de dos factores."
|
||||
"twoFactorModalChangeCredentialsTitle" = "Cambiar credenciales"
|
||||
"twoFactorModalChangeCredentialsStep" = "Ingrese el código de la aplicación para cambiar las credenciales del administrador."
|
||||
"twoFactorModalSetSuccess" = "La autenticación de dos factores se ha establecido con éxito"
|
||||
"twoFactorModalDeleteSuccess" = "La autenticación de dos factores se ha eliminado con éxito"
|
||||
"twoFactorModalError" = "Código incorrecto"
|
||||
|
|
|
@ -541,6 +541,8 @@
|
|||
"twoFactorModalFirstStep" = "1. این کد QR را در برنامه احراز هویت اسکن کنید یا توکن کنار کد QR را کپی کرده و در برنامه بچسبانید"
|
||||
"twoFactorModalSecondStep" = "2. کد را از برنامه وارد کنید"
|
||||
"twoFactorModalRemoveStep" = "برای حذف احراز هویت دو مرحلهای، کد را از برنامه وارد کنید."
|
||||
"twoFactorModalChangeCredentialsTitle" = "تغییر اعتبارنامهها"
|
||||
"twoFactorModalChangeCredentialsStep" = "برای تغییر اعتبارنامههای مدیر، کد را از برنامه وارد کنید."
|
||||
"twoFactorModalSetSuccess" = "احراز هویت دو مرحلهای با موفقیت برقرار شد"
|
||||
"twoFactorModalDeleteSuccess" = "احراز هویت دو مرحلهای با موفقیت حذف شد"
|
||||
"twoFactorModalError" = "کد نادرست"
|
||||
|
|
|
@ -541,6 +541,8 @@
|
|||
"twoFactorModalFirstStep" = "1. Pindai kode QR ini di aplikasi autentikasi atau salin token di dekat kode QR dan tempelkan ke aplikasi"
|
||||
"twoFactorModalSecondStep" = "2. Masukkan kode dari aplikasi"
|
||||
"twoFactorModalRemoveStep" = "Masukkan kode dari aplikasi untuk menghapus autentikasi dua faktor."
|
||||
"twoFactorModalChangeCredentialsTitle" = "Ubah kredensial"
|
||||
"twoFactorModalChangeCredentialsStep" = "Masukkan kode dari aplikasi untuk mengubah kredensial administrator."
|
||||
"twoFactorModalSetSuccess" = "Autentikasi dua faktor telah berhasil dibuat"
|
||||
"twoFactorModalDeleteSuccess" = "Autentikasi dua faktor telah berhasil dihapus"
|
||||
"twoFactorModalError" = "Kode salah"
|
||||
|
|
|
@ -541,6 +541,8 @@
|
|||
"twoFactorModalFirstStep" = "1. 認証アプリでこのQRコードをスキャンするか、QRコード近くのトークンをコピーしてアプリに貼り付けます"
|
||||
"twoFactorModalSecondStep" = "2. アプリからコードを入力してください"
|
||||
"twoFactorModalRemoveStep" = "二段階認証を削除するには、アプリからコードを入力してください。"
|
||||
"twoFactorModalChangeCredentialsTitle" = "認証情報の変更"
|
||||
"twoFactorModalChangeCredentialsStep" = "管理者の認証情報を変更するには、アプリケーションからコードを入力してください。"
|
||||
"twoFactorModalSetSuccess" = "二要素認証が正常に設定されました"
|
||||
"twoFactorModalDeleteSuccess" = "二要素認証が正常に削除されました"
|
||||
"twoFactorModalError" = "コードが間違っています"
|
||||
|
|
|
@ -541,6 +541,8 @@
|
|||
"twoFactorModalFirstStep" = "1. Escaneie este QR code no aplicativo de autenticação ou copie o token próximo ao QR code e cole no aplicativo"
|
||||
"twoFactorModalSecondStep" = "2. Digite o código do aplicativo"
|
||||
"twoFactorModalRemoveStep" = "Digite o código do aplicativo para remover a autenticação de dois fatores."
|
||||
"twoFactorModalChangeCredentialsTitle" = "Alterar credenciais"
|
||||
"twoFactorModalChangeCredentialsStep" = "Insira o código do aplicativo para alterar as credenciais do administrador."
|
||||
"twoFactorModalSetSuccess" = "A autenticação de dois fatores foi estabelecida com sucesso"
|
||||
"twoFactorModalDeleteSuccess" = "A autenticação de dois fatores foi excluída com sucesso"
|
||||
"twoFactorModalError" = "Código incorreto"
|
||||
|
|
|
@ -541,6 +541,8 @@
|
|||
"twoFactorModalFirstStep" = "1. Отсканируйте этот QR-код в приложении для аутентификации или скопируйте токен рядом с QR-кодом и вставьте его в приложение"
|
||||
"twoFactorModalSecondStep" = "2. Введите код из приложения"
|
||||
"twoFactorModalRemoveStep" = "Введите код из приложения, чтобы отключить двухфакторную аутентификацию."
|
||||
"twoFactorModalChangeCredentialsTitle" = "Изменить учетные данные"
|
||||
"twoFactorModalChangeCredentialsStep" = "Введите код из приложения, чтобы изменить учетные данные администратора."
|
||||
"twoFactorModalSetSuccess" = "Двухфакторная аутентификация была успешно установлена"
|
||||
"twoFactorModalDeleteSuccess" = "Двухфакторная аутентификация была успешно удалена"
|
||||
"twoFactorModalError" = "Неверный код"
|
||||
|
|
|
@ -541,6 +541,8 @@
|
|||
"twoFactorModalFirstStep" = "1. Bu QR kodunu doğrulama uygulamasında tarayın veya QR kodunun yanındaki token'ı kopyalayıp uygulamaya yapıştırın"
|
||||
"twoFactorModalSecondStep" = "2. Uygulamadaki kodu girin"
|
||||
"twoFactorModalRemoveStep" = "İki adımlı doğrulamayı kaldırmak için uygulamadaki kodu girin."
|
||||
"twoFactorModalChangeCredentialsTitle" = "Kimlik bilgilerini değiştir"
|
||||
"twoFactorModalChangeCredentialsStep" = "Yönetici kimlik bilgilerini değiştirmek için uygulamadaki kodu girin."
|
||||
"twoFactorModalSetSuccess" = "İki faktörlü kimlik doğrulama başarıyla kuruldu"
|
||||
"twoFactorModalDeleteSuccess" = "İki faktörlü kimlik doğrulama başarıyla silindi"
|
||||
"twoFactorModalError" = "Yanlış kod"
|
||||
|
|
|
@ -541,6 +541,8 @@
|
|||
"twoFactorModalFirstStep" = "1. Відскануйте цей QR-код у програмі для аутентифікації або скопіюйте токен біля QR-коду та вставте його в програму"
|
||||
"twoFactorModalSecondStep" = "2. Введіть код з програми"
|
||||
"twoFactorModalRemoveStep" = "Введіть код з програми, щоб вимкнути двофакторну аутентифікацію."
|
||||
"twoFactorModalChangeCredentialsTitle" = "Змінити облікові дані"
|
||||
"twoFactorModalChangeCredentialsStep" = "Введіть код з додатку, щоб змінити облікові дані адміністратора."
|
||||
"twoFactorModalSetSuccess" = "Двофакторна аутентифікація була успішно встановлена"
|
||||
"twoFactorModalDeleteSuccess" = "Двофакторна аутентифікація була успішно видалена"
|
||||
"twoFactorModalError" = "Невірний код"
|
||||
|
|
|
@ -541,6 +541,8 @@
|
|||
"twoFactorModalFirstStep" = "1. Quét mã QR này trong ứng dụng xác thực hoặc sao chép mã token gần mã QR và dán vào ứng dụng"
|
||||
"twoFactorModalSecondStep" = "2. Nhập mã từ ứng dụng"
|
||||
"twoFactorModalRemoveStep" = "Nhập mã từ ứng dụng để xóa xác thực hai yếu tố."
|
||||
"twoFactorModalChangeCredentialsTitle" = "Thay đổi thông tin xác thực"
|
||||
"twoFactorModalChangeCredentialsStep" = "Nhập mã từ ứng dụng để thay đổi thông tin xác thực quản trị viên."
|
||||
"twoFactorModalSetSuccess" = "Xác thực hai yếu tố đã được thiết lập thành công"
|
||||
"twoFactorModalDeleteSuccess" = "Xác thực hai yếu tố đã được xóa thành công"
|
||||
"twoFactorModalError" = "Mã sai"
|
||||
|
|
|
@ -541,6 +541,8 @@
|
|||
"twoFactorModalFirstStep" = "1. 在认证应用程序中扫描此QR码,或复制QR码附近的令牌并粘贴到应用程序中"
|
||||
"twoFactorModalSecondStep" = "2. 输入应用程序中的验证码"
|
||||
"twoFactorModalRemoveStep" = "输入应用程序中的验证码以移除双重认证。"
|
||||
"twoFactorModalChangeCredentialsTitle" = "更改凭据"
|
||||
"twoFactorModalChangeCredentialsStep" = "输入应用程序中的代码以更改管理员凭据。"
|
||||
"twoFactorModalSetSuccess" = "双因素认证已成功建立"
|
||||
"twoFactorModalDeleteSuccess" = "双因素认证已成功删除"
|
||||
"twoFactorModalError" = "验证码错误"
|
||||
|
|
|
@ -543,6 +543,8 @@
|
|||
"twoFactorModalFirstStep" = "1. 在認證應用程式中掃描此QR碼,或複製QR碼附近的令牌並貼到應用程式中"
|
||||
"twoFactorModalSecondStep" = "2. 輸入應用程式中的驗證碼"
|
||||
"twoFactorModalRemoveStep" = "輸入應用程式中的驗證碼以移除雙重認證。"
|
||||
"twoFactorModalChangeCredentialsTitle" = "更改憑證"
|
||||
"twoFactorModalChangeCredentialsStep" = "輸入應用程式中的代碼以更改管理員憑證。"
|
||||
"twoFactorModalSetSuccess" = "雙重身份驗證已成功建立"
|
||||
"twoFactorModalDeleteSuccess" = "雙重身份驗證已成功刪除"
|
||||
"twoFactorModalError" = "驗證碼錯誤"
|
||||
|
|
Loading…
Reference in a new issue