mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 10:25:52 +02:00
feat: hide some parts of jwt secret and node secret
This commit is contained in:
parent
45a136380d
commit
2b6e84ab62
19 changed files with 637 additions and 403 deletions
|
@ -1,12 +1,15 @@
|
|||
package model
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type Auth struct {
|
||||
Model
|
||||
|
||||
Name string `json:"name"`
|
||||
Password string `json:"-"`
|
||||
Status bool `json:"status" gorm:"default:1"`
|
||||
OTPSecret []byte `json:"-" gorm:"type:blob"`
|
||||
Name string `json:"name"`
|
||||
Password string `json:"-"`
|
||||
Status bool `json:"status" gorm:"default:1"`
|
||||
OTPSecret []byte `json:"-" gorm:"type:blob"`
|
||||
Enabled2FA bool `json:"enabled_2fa" gorm:"-"`
|
||||
}
|
||||
|
||||
type AuthToken struct {
|
||||
|
@ -15,6 +18,11 @@ type AuthToken struct {
|
|||
ExpiredAt int64 `json:"expired_at" gorm:"default:0"`
|
||||
}
|
||||
|
||||
func (u *Auth) AfterFind(tx *gorm.DB) error {
|
||||
u.Enabled2FA = u.EnabledOTP()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *Auth) EnabledOTP() bool {
|
||||
return len(u.OTPSecret) != 0
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue