diff --git a/backend/app/service/auth.go b/backend/app/service/auth.go index e9ec66b01..dc89b55e5 100644 --- a/backend/app/service/auth.go +++ b/backend/app/service/auth.go @@ -10,6 +10,7 @@ import ( "github.com/1Panel-dev/1Panel/backend/global" "github.com/1Panel-dev/1Panel/backend/utils/encrypt" "github.com/1Panel-dev/1Panel/backend/utils/jwt" + "github.com/1Panel-dev/1Panel/backend/utils/mfa" "github.com/gin-gonic/gin" "github.com/pkg/errors" uuid "github.com/satori/go.uuid" @@ -68,11 +69,7 @@ func (u *AuthService) Login(c *gin.Context, info dto.Login) (*dto.UserLoginInfo, return nil, err } if mfa.Value == "enable" { - mfaSecret, err := settingRepo.Get(settingRepo.WithByKey("MFASecret")) - if err != nil { - return nil, err - } - return &dto.UserLoginInfo{Name: nameSetting.Value, MfaStatus: mfa.Value, MfaSecret: mfaSecret.Value}, nil + return &dto.UserLoginInfo{Name: nameSetting.Value, MfaStatus: mfa.Value}, nil } return u.generateSession(c, info.Name, info.AuthMethod) @@ -91,7 +88,16 @@ func (u *AuthService) MFALogin(c *gin.Context, info dto.MFALogin) (*dto.UserLogi if err != nil { return nil, constant.ErrAuth } - if info.Password != pass && nameSetting.Value == info.Name { + if info.Password != pass && nameSetting.Value != info.Name { + return nil, constant.ErrAuth + } + + mfaSecret, err := settingRepo.Get(settingRepo.WithByKey("MFASecret")) + if err != nil { + return nil, err + } + success := mfa.ValidCode(info.Code, mfaSecret.Value) + if !success { return nil, constant.ErrAuth } diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index eb6b47c4c..6822b38aa 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -105,6 +105,7 @@ export default { rePassword: 'Confirm Password', welcome: 'Welcome back, please enter your username and password to log in!', errorAuthInfo: 'The user name or password you entered is incorrect, please re-enter!', + errorMfaInfo: 'Incorrect authentication information, please try again!', captchaHelper: 'Please enter the verification code', errorCaptcha: 'Verification code error!', safeEntrance: 'Please use the correct entry to log in to the panel', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 3b206857b..9e48688ec 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -110,6 +110,7 @@ export default { rePassword: '确认密码', welcome: '欢迎回来,请输入用户名和密码登录!', errorAuthInfo: '您输入的用户名或密码不正确,请重新输入!', + errorMfaInfo: '错误的验证信息,请重试!', captchaHelper: '请输入验证码', errorCaptcha: '验证码错误!', safeEntrance: '请使用正确的入口登录面板', diff --git a/frontend/src/views/database/redis/setting/index.vue b/frontend/src/views/database/redis/setting/index.vue index 1242986ed..277ca4b21 100644 --- a/frontend/src/views/database/redis/setting/index.vue +++ b/frontend/src/views/database/redis/setting/index.vue @@ -46,6 +46,7 @@ theme="cobalt" :styleActiveLine="true" :extensions="extensions" + @ready="handleReady" v-model="redisConf" /> @@ -127,7 +128,7 @@