hash passwords in json file

Signed-off-by: Mitaka Jin <jin@mitaka.nl>
This commit is contained in:
Mitaka Jin 2020-12-12 11:30:53 +01:00
parent 68058a356e
commit 1ce08cfe40
3 changed files with 37 additions and 26 deletions

View file

@ -3,5 +3,5 @@ package util
// Runtime config
var (
DisableLogin bool
BindAddress string
BindAddress string
)

View file

@ -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)
}