// SetupMySQLSeeds creates the first user
SetupMySQLSeeds creates the first user
// SetupMySQLSeeds creates the first user
func (a *API) SetupMySQLSeeds() error {
	store := mysql.New(a.MySQLDatabase)
	user := &models.User{
		FirstName: a.Config.GetString("admin_firstname"),
		LastName:  a.Config.GetString("admin_lastname"),
		Password:  a.Config.GetString("admin_password"),
		Email:     a.Config.GetString("admin_email"),
		Phone:     a.Config.GetString("admin_phone"),
		Role:      "admin",
	}
	userExists, _ := store.UserExists(user.Email)
	if userExists {
		logrus.Infoln(`Seed user already exists`)
		return nil
	}
	if store.CreateUser(user) != nil {
		logrus.Warnln(`Error when creating user`)
	}
	if store.ActivateUser(user.Key, string(user.ID)) != nil {
		logrus.Warnln(`Error when activating user`)
	}
	return nil
}
func ( a * API ) SetupMySQLSeeds ( ) error { store := mysql . New ( a . MySQLDatabase ) user := & models . User { FirstName : a . Config . GetString ( " " ) , LastName : a . Config . GetString ( " " ) , Password : a . Config . GetString ( " " ) , Email : a . Config . GetString ( " " ) , Phone : a . Config . GetString ( " " ) , Role : " " , } userExists , _ := store . UserExists ( user . Email ) if userExists { logrus . Infoln ( `Seed user already exists` ) return nil } if store . CreateUser ( user ) != nil { logrus . Warnln ( `Error when creating user` ) } if store . ActivateUser ( user . Key , string ( user . ID ) ) != nil { logrus . Warnln ( `Error when activating user` ) } return nil }
SetupMySQLSeeds creates the first user
SetupMySQLSeeds creates the first user