Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
actions: subscribe new users with all categories
Browse files Browse the repository at this point in the history
This should be configurable from the application level, giving a list of
default categories to subscribe to.

Updates go-saloon/saloon#8.
  • Loading branch information
sbinet committed Mar 23, 2018
1 parent 0b6d698 commit 3afa551
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions actions/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ func UsersRegisterPost(c buffalo.Context) error {
}
user.Avatar = avatar
tx := c.Value("tx").(*pop.Connection)

// subscribe user with all categories.
// FIXME(sbinet) we should make the list of default categories
// customizable at the application level...
// see:
// go-saloon/saloon#8
cats := new(models.Categories)
if err := tx.All(cats); err != nil {
return errors.WithStack(err)
}
for _, cat := range *cats {
user.AddSubscription(cat.ID)
}

verrs, err := user.Create(tx)
if err != nil {
return errors.WithStack(err)
Expand Down

0 comments on commit 3afa551

Please sign in to comment.