mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
fix: incorrect status of enabled 2fa of user #577
This commit is contained in:
parent
f2a586ca78
commit
2f7070377f
4 changed files with 31 additions and 11 deletions
|
@ -42,13 +42,19 @@ function batchUpgrade() {
|
||||||
|
|
||||||
<BatchUpgrader ref="refUpgrader" />
|
<BatchUpgrader ref="refUpgrader" />
|
||||||
|
|
||||||
<FooterToolBar v-if="selectedNodes?.length > 0">
|
<FooterToolBar>
|
||||||
|
<ATooltip
|
||||||
|
:title="$gettext('Please select at least one node to upgrade')"
|
||||||
|
placement="topLeft"
|
||||||
|
>
|
||||||
<AButton
|
<AButton
|
||||||
|
:disabled="selectedNodeIds.length === 0"
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="batchUpgrade"
|
@click="batchUpgrade"
|
||||||
>
|
>
|
||||||
{{ $gettext('Upgrade') }}
|
{{ $gettext('Upgrade') }}
|
||||||
</AButton>
|
</AButton>
|
||||||
|
</ATooltip>
|
||||||
</FooterToolBar>
|
</FooterToolBar>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -229,7 +229,7 @@ async function handlePasskeyLogin() {
|
||||||
:two-f-a-status="{
|
:two-f-a-status="{
|
||||||
enabled: true,
|
enabled: true,
|
||||||
otp_status: true,
|
otp_status: true,
|
||||||
passkey_status: true,
|
passkey_status: false,
|
||||||
}"
|
}"
|
||||||
@submit-o-t-p="handleOTPSubmit"
|
@submit-o-t-p="handleOTPSubmit"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -60,6 +60,13 @@ func (c *ConfigPayload) mkCertificateDir() (err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, err = os.Stat(c.CertificateDir); os.IsNotExist(err) {
|
||||||
|
err = os.MkdirAll(c.CertificateDir, 0755)
|
||||||
|
if err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// For windows, replace * with # (issue #403)
|
// For windows, replace * with # (issue #403)
|
||||||
c.CertificateDir = strings.ReplaceAll(c.CertificateDir, "*", "#")
|
c.CertificateDir = strings.ReplaceAll(c.CertificateDir, "*", "#")
|
||||||
if _, err = os.Stat(c.CertificateDir); os.IsNotExist(err) {
|
if _, err = os.Stat(c.CertificateDir); os.IsNotExist(err) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package model
|
||||||
import (
|
import (
|
||||||
"github.com/go-webauthn/webauthn/webauthn"
|
"github.com/go-webauthn/webauthn/webauthn"
|
||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
|
@ -12,6 +13,7 @@ type User struct {
|
||||||
Password string `json:"-"`
|
Password string `json:"-"`
|
||||||
Status bool `json:"status" gorm:"default:1"`
|
Status bool `json:"status" gorm:"default:1"`
|
||||||
OTPSecret []byte `json:"-" gorm:"type:blob"`
|
OTPSecret []byte `json:"-" gorm:"type:blob"`
|
||||||
|
EnabledTwoFA bool `json:"enabled_2fa" gorm:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthToken struct {
|
type AuthToken struct {
|
||||||
|
@ -24,6 +26,11 @@ func (u *User) TableName() string {
|
||||||
return "auths"
|
return "auths"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *User) AfterFind(_ *gorm.DB) error {
|
||||||
|
u.EnabledTwoFA = u.Enabled2FA()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (u *User) EnabledOTP() bool {
|
func (u *User) EnabledOTP() bool {
|
||||||
return len(u.OTPSecret) != 0
|
return len(u.OTPSecret) != 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue