package Seeder
|
|
|
|
import (
|
|
"encoding/base64"
|
|
|
|
"git.tovijaeschke.xyz/tovi/Envelope/Backend/Api/Auth"
|
|
"git.tovijaeschke.xyz/tovi/Envelope/Backend/Database"
|
|
)
|
|
|
|
var userNames = []string{
|
|
"assuredcoot",
|
|
"quotesteeve",
|
|
"blueberriessiemens",
|
|
"eliteexaggerate",
|
|
"twotrice",
|
|
"moderagged",
|
|
"duleelderly",
|
|
"stringdetailed",
|
|
"nodesanymore",
|
|
"sacredpolitical",
|
|
"pajamasenergy",
|
|
"Multiscience",
|
|
"Exequies",
|
|
"Nebulae",
|
|
"Synartesis",
|
|
"LinklingKaput",
|
|
"Gumption",
|
|
"Festooned",
|
|
"Ratatouille",
|
|
"VersusBoing",
|
|
"Jiggermast",
|
|
"Ambsase",
|
|
"Ard3pic",
|
|
"Smegma",
|
|
"Vaporiform",
|
|
"Agromania",
|
|
"GleetrAlgor",
|
|
"Zymurgy",
|
|
"Nipperkin",
|
|
"Thespian",
|
|
"Mewling",
|
|
"Scram",
|
|
"Fizgig",
|
|
}
|
|
|
|
func createUser(username string) (Database.User, error) {
|
|
var (
|
|
userData Database.User
|
|
userKey AesKey
|
|
password string
|
|
err error
|
|
)
|
|
|
|
userKey, err = GenerateAesKey()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
password, err = Auth.HashPassword("password")
|
|
if err != nil {
|
|
return Database.User{}, err
|
|
}
|
|
|
|
userData = Database.User{
|
|
Username: username,
|
|
Password: password,
|
|
AsymmetricPrivateKey: EncryptedPrivateKey,
|
|
AsymmetricPublicKey: PublicKey,
|
|
SymmetricKey: base64.StdEncoding.EncodeToString(
|
|
EncryptWithPublicKey(userKey.Key, decodedPublicKey),
|
|
),
|
|
}
|
|
|
|
err = (&userData).CreateUser()
|
|
return userData, err
|
|
}
|
|
|
|
// SeedUsers used to create dummy users for testing & development
|
|
func SeedUsers() {
|
|
var (
|
|
i int
|
|
err error
|
|
)
|
|
|
|
// Seed users used for conversation seeding
|
|
_, err = createUser("testUser")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
_, err = createUser("ATestUser2")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
for i = 0; i < len(userNames); i++ {
|
|
_, err = createUser(userNames[i])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
}
|