36 lines
649 B
Go
36 lines
649 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
|
|
"git.red-panda.pet/pandaware/house/backend/db"
|
|
"github.com/google/uuid"
|
|
"golang.org/x/crypto/bcrypt"
|
|
)
|
|
|
|
func seedDevData(sqlite *sql.DB) {
|
|
ctx := context.Background()
|
|
tx := db.New(sqlite)
|
|
|
|
id := uuid.Must(uuid.NewV7())
|
|
|
|
user, err := tx.CreateUser(ctx, db.CreateUserParams{
|
|
ID: id.String(),
|
|
Username: "red",
|
|
})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
password, err := bcrypt.GenerateFromPassword([]byte("password"), bcrypt.DefaultCost)
|
|
|
|
_, err = tx.UpdateUserPassword(ctx, db.UpdateUserPasswordParams{
|
|
ID: user.ID,
|
|
Password: password,
|
|
})
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|