1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

Updated to use go modules and updated UUID libary

This commit is contained in:
robrotheram
2019-10-07 23:39:43 +01:00
parent 9b16ee9461
commit 12b3bec2f6
3 changed files with 161 additions and 1 deletions

View File

@@ -163,7 +163,12 @@ func migrateLanguages(db *gorm.DB, cfg *models.Config) {
func addDefaultUser(db *gorm.DB, cfg *models.Config) {
pw := md5.Sum([]byte(models.DefaultPassword))
pwString := hex.EncodeToString(pw[:])
apiKey := uuid.Must(uuid.NewV4()).String()
var err error
apiKey := uuid.Must(uuid.NewV4(), err).String()
if err != nil {
log.Println("Unable to create api key.")
log.Fatal(err)
}
u := &models.User{ID: models.DefaultUser, Password: pwString, ApiKey: apiKey}
result := db.FirstOrCreate(u, &models.User{ID: u.ID})
if result.Error != nil {