コード例 #1
0
ファイル: db.go プロジェクト: jwmiller19/revel-modz
func fillMailTables() {
	var err error
	for _, um := range dev_users {
		if um.Maillist == "" {
			continue
		}
		err = maillist.AddUser(TestDB, um.UserId, um.UserName, um.Maillist)
		checkERROR(err)
	}
	revel.INFO.Println("Filled maillist DBs")
}
コード例 #2
0
ファイル: maillist.go プロジェクト: jwmiller19/revel-modz
func (c App) addNewMaillistUser(email, list string) error {

	// uuid := get random number (that isn't used already)
	uuid, err := user.GenerateNewUserId(c.Txn)
	if err != nil {
		return err
	}

	err = user.AddUserBasic(TestDB, uuid, email)
	checkERROR(err)

	err = maillist.AddUser(TestDB, uuid, email, list)
	checkERROR(err)

	return nil
}
コード例 #3
0
ファイル: signup.go プロジェクト: jwmiller19/revel-modz
func (c App) RegisterPost(userregister *models.UserRegister) revel.Result {
	userregister.Validate(c.Validation)

	if c.Validation.HasErrors() {
		c.Validation.Keep()
		c.FlashParams()
		return c.Redirect(routes.App.Register())
	}

	// check that this email is not in the DB already
	UB, err := user.GetUserBasicByName(c.Txn, userregister.Email)
	checkERROR(err)

	if UB != nil {
		c.Validation.Error("Email already taken").Key("userregister.Email")
		c.Validation.Keep()
		c.FlashParams()
		return c.Redirect(routes.App.Signup())
	}

	// uuid := get random number (that isn't used already)
	uuid, err := user.GenerateNewUserId(c.Txn)
	checkERROR(err)

	// add user to tables
	// TODO do something more with the errors
	err = user.AddUserBasic(TestDB, uuid, userregister.Email)
	checkERROR(err)

	err = auth.AddUser(TestDB, UB.UserId, userregister.Password)
	checkERROR(err)

	// TODO  which mailing lists did they check off?
	err = maillist.AddUser(TestDB, uuid, userregister.Email, "weekly")
	checkERROR(err)

	// TODO add address / phone DB insert
	// ...

	c.Flash.Out["heading"] = "Thanks for Joining!"
	c.Flash.Out["message"] = "you should be receiving an email at " +
		userregister.Email + " to confirm and activate your account."

	return c.Redirect(routes.App.Result())
}
コード例 #4
0
ファイル: signup.go プロジェクト: slnaing07/revel-modz
func (c App) RegisterPost(userregister *models.UserRegister) revel.Result {
	userregister.Validate(c.Validation)

	if c.Validation.HasErrors() {
		c.Validation.Keep()
		c.FlashParams()
		return c.Redirect(routes.App.Register())
	}

	// check that this email is not in the DB already
	UB, err := user.GetUserBasicByName(c.Txn, userregister.Email)
	checkERROR(err)

	if UB != nil {
		c.Validation.Error("Email already taken").Key("userregister.Email")
		c.Validation.Keep()
		c.FlashParams()
		return c.Redirect(routes.App.Signup())
	}

	// uuid := get random number (that isn't used already)
	uuid, err := user.GenerateNewUserId(c.Txn)
	checkERROR(err)

	// update visitor info in DB with UserId
	c.updateVisitorWithUserIdPanic()

	// add user to tables
	// TODO do something more with the errors
	err = user.AddUserBasic(TestDB, uuid, userregister.Email)
	checkERROR(err)

	err = auth.AddUser(TestDB, UB.UserId, userregister.Password)
	checkERROR(err)

	// TODO  which mailing lists did they check off?
	err = maillist.AddUser(TestDB, uuid, userregister.Email, "weekly")
	checkERROR(err)

	// TODO add address / phone DB insert
	// ...
	addy := &user.UserAddress{
		UserId:       uuid,
		AddressType:  "default",
		AddressLine1: userregister.Address1,
		AddressLine2: userregister.Address2,
		City:         userregister.City,
		State:        userregister.State,
		Zip:          userregister.Zipcode,
		Country:      userregister.Country,
	}
	err = user.AddUserAddress(TestDB, addy)
	checkERROR(err)

	err = user.AddUserPhone(TestDB, uuid, "default", userregister.PhoneNumber)
	checkERROR(err)

	c.Flash.Out["heading"] = "Thanks for Joining!"
	c.Flash.Out["message"] = "you should be receiving an email at " +
		userregister.Email + " to confirm and activate your account."

	return c.Redirect(routes.App.Result())
}