mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-09-06 01:30:48 +03:00
hash passwords in json file
Signed-off-by: Mitaka Jin <jin@mitaka.nl>
This commit is contained in:
parent
68058a356e
commit
1ce08cfe40
3 changed files with 37 additions and 26 deletions
|
@ -3,5 +3,5 @@ package util
|
|||
// Runtime config
|
||||
var (
|
||||
DisableLogin bool
|
||||
BindAddress string
|
||||
BindAddress string
|
||||
)
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/ngoduykhanh/wireguard-ui/model"
|
||||
"github.com/sdomino/scribble"
|
||||
"github.com/skip2/go-qrcode"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||
)
|
||||
|
||||
|
@ -113,7 +114,10 @@ func InitDB() error {
|
|||
|
||||
user := new(model.User)
|
||||
user.Username = defaultUsername
|
||||
user.Password = defaultPassword
|
||||
user.Password, err = bcrypt.GenerateFromPassword(defaultPassword, bcrypt.MaxCost)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
db.Write("server", "users", user)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue