Skip to content

Commit 2f70703

Browse files
committed
fix: incorrect status of enabled 2fa of user #577
1 parent f2a586c commit 2f70703

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

app/src/views/environment/Environment.vue

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,19 @@ function batchUpgrade() {
4242

4343
<BatchUpgrader ref="refUpgrader" />
4444

45-
<FooterToolBar v-if="selectedNodes?.length > 0">
46-
<AButton
47-
type="primary"
48-
@click="batchUpgrade"
45+
<FooterToolBar>
46+
<ATooltip
47+
:title="$gettext('Please select at least one node to upgrade')"
48+
placement="topLeft"
4949
>
50-
{{ $gettext('Upgrade') }}
51-
</AButton>
50+
<AButton
51+
:disabled="selectedNodeIds.length === 0"
52+
type="primary"
53+
@click="batchUpgrade"
54+
>
55+
{{ $gettext('Upgrade') }}
56+
</AButton>
57+
</ATooltip>
5258
</FooterToolBar>
5359
</div>
5460
</template>

app/src/views/other/Login.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ async function handlePasskeyLogin() {
229229
:two-f-a-status="{
230230
enabled: true,
231231
otp_status: true,
232-
passkey_status: true,
232+
passkey_status: false,
233233
}"
234234
@submit-o-t-p="handleOTPSubmit"
235235
/>

internal/cert/payload.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ func (c *ConfigPayload) mkCertificateDir() (err error) {
6060
}
6161
}
6262

63+
if _, err = os.Stat(c.CertificateDir); os.IsNotExist(err) {
64+
err = os.MkdirAll(c.CertificateDir, 0755)
65+
if err == nil {
66+
return nil
67+
}
68+
}
69+
6370
// For windows, replace * with # (issue #403)
6471
c.CertificateDir = strings.ReplaceAll(c.CertificateDir, "*", "#")
6572
if _, err = os.Stat(c.CertificateDir); os.IsNotExist(err) {

model/auth.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ package model
33
import (
44
"github.com/go-webauthn/webauthn/webauthn"
55
"github.com/spf13/cast"
6+
"gorm.io/gorm"
67
)
78

89
type User struct {
910
Model
1011

11-
Name string `json:"name"`
12-
Password string `json:"-"`
13-
Status bool `json:"status" gorm:"default:1"`
14-
OTPSecret []byte `json:"-" gorm:"type:blob"`
12+
Name string `json:"name"`
13+
Password string `json:"-"`
14+
Status bool `json:"status" gorm:"default:1"`
15+
OTPSecret []byte `json:"-" gorm:"type:blob"`
16+
EnabledTwoFA bool `json:"enabled_2fa" gorm:"-"`
1517
}
1618

1719
type AuthToken struct {
@@ -24,6 +26,11 @@ func (u *User) TableName() string {
2426
return "auths"
2527
}
2628

29+
func (u *User) AfterFind(_ *gorm.DB) error {
30+
u.EnabledTwoFA = u.Enabled2FA()
31+
return nil
32+
}
33+
2734
func (u *User) EnabledOTP() bool {
2835
return len(u.OTPSecret) != 0
2936
}

0 commit comments

Comments
 (0)