Fix GetCaptchaStatus() crash if not logged in

This commit is contained in:
Yang Luo
2024-01-13 18:04:38 +08:00
parent 177f2f2f11
commit 39d6bc10f7
2 changed files with 13 additions and 9 deletions

View File

@ -980,16 +980,20 @@ func (c *ApiController) GetCaptchaStatus() {
return return
} }
failedSigninLimit, _, err := object.GetFailedSigninConfigByUser(user) captchaEnabled := false
if err != nil { if user != nil {
c.ResponseError(err.Error()) var failedSigninLimit int
return failedSigninLimit, _, err = object.GetFailedSigninConfigByUser(user)
if err != nil {
c.ResponseError(err.Error())
return
}
if user.SigninWrongTimes >= failedSigninLimit {
captchaEnabled = true
}
} }
var captchaEnabled bool
if user != nil && user.SigninWrongTimes >= failedSigninLimit {
captchaEnabled = true
}
c.ResponseOk(captchaEnabled) c.ResponseOk(captchaEnabled)
} }

View File

@ -193,7 +193,7 @@ class ProviderTable extends React.Component {
title: i18next.t("application:Rule"), title: i18next.t("application:Rule"),
dataIndex: "rule", dataIndex: "rule",
key: "rule", key: "rule",
width: "100px", width: "120px",
render: (text, record, index) => { render: (text, record, index) => {
if (record.provider?.type === "Google") { if (record.provider?.type === "Google") {
if (text === "None") { if (text === "None") {