// SetupMongoSeeds creates the first user
SetupMongoSeeds creates the first user
// SetupMongoSeeds creates the first user
func (a *API) SetupMongoSeeds() error {
	store := mongodb.New(nil, a.MongoDatabase, a.Config.GetString("mongo_db_name"))
	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, _, err := store.UserExists(user.Email)
	if userExists {
		utils.Log(nil, "warn", `Seed user already exists`, err)
	} else {
		utils.Log(nil, "info", "User doesn't exists already")
	}
	err = store.CreateUser(user)
	if err != nil {
		utils.Log(nil, "warn", `Error when creating user:`, err)
		user, _ = store.GetUser(params.M{"email": a.Config.GetString("admin_email")})
	} else {
		utils.Log(nil, "info", "User well created")
		err = store.ActivateUser(user.Key, user.ID)
		if err != nil {
			utils.Log(nil, "warn", `Error when activating user`, err)
		} else {
			utils.Log(nil, "info", "User well activated")
		}
	}
	return nil
}
func ( a * API ) SetupMongoSeeds ( ) error { store := mongodb . New ( nil , a . MongoDatabase , a . Config . GetString ( " " ) ) 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 , _ , err := store . UserExists ( user . Email ) if userExists { utils . Log ( nil , " " , `Seed user already exists` , err ) } else { utils . Log ( nil , " " , " " ) } err = store . CreateUser ( user ) if err != nil { utils . Log ( nil , " " , `Error when creating user:` , err ) user , _ = store . GetUser ( params . M { " " : a . Config . GetString ( " " ) } ) } else { utils . Log ( nil , " " , " " ) err = store . ActivateUser ( user . Key , user . ID ) if err != nil { utils . Log ( nil , " " , `Error when activating user` , err ) } else { utils . Log ( nil , " " , " " ) } } return nil }
SetupMongoSeeds creates the first user
SetupMongoSeeds creates the first user