// SetupPostgreSeeds creates the first user
SetupPostgreSeeds creates the first user
// SetupPostgreSeeds creates the first user
func (a *API) SetupPostgreSeeds() error {
	fmt.Println("Setup postgre seeds")
	store := postgresql.New(a.PostgreDatabase)
	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, userFound, err := store.UserExists(user.Email)
	if userExists {
		logrus.Infoln(`Seed user already exists`, err, userFound)
	} else {
		if err := store.CreateUser(user); err != nil {
			logrus.Warnln(`Error when creating user:`, err)
		}
	}
	dbUser, err := store.GetUser(params.M{"email": a.Config.GetString("admin_email")})
	if err != nil {
		logrus.Warnln(err)
	}
	fmt.Println("Found user", dbUser.ID, ":", dbUser)
	if err := store.ActivateUser(dbUser.Key , dbUser.Email); err != nil {
		logrus.Warnln(`Error when activating user`, err)
	}
	fmt.Println("Checked")
	return nil
}
func ( a * API ) SetupPostgreSeeds ( ) error { fmt . Println ( " " ) store := postgresql . New ( a . PostgreDatabase ) 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 , userFound , err := store . UserExists ( user . Email ) if userExists { logrus . Infoln ( `Seed user already exists` , err , userFound ) } else { if err := store . CreateUser ( user ) ; err != nil { logrus . Warnln ( `Error when creating user:` , err ) } } dbUser , err := store . GetUser ( params . M { " " : a . Config . GetString ( " " ) } ) if err != nil { logrus . Warnln ( err ) } fmt . Println ( " " , dbUser . ID , " " , dbUser ) if err := store . ActivateUser ( dbUser . Key , dbUser . Email ) ; err != nil { logrus . Warnln ( `Error when activating user` , err ) } fmt . Println ( " " ) return nil }
SetupPostgreSeeds creates the first user
SetupPostgreSeeds creates the first user
/*strconv.Itoa(dbUser.Id)*/