Skip to content

Commit

Permalink
Set roles when becoming attendee (#7269)
Browse files Browse the repository at this point in the history
* Set roles when becoming attendee

* Add in all places
  • Loading branch information
iHiD authored Jan 9, 2025
1 parent 0346ae5 commit 7478efb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions app/commands/user/become_bootcamp_attendee.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class User::BecomeBootcampAttendee
include Mandate

initialize_with :user

def call
user.update!(bootcamp_attendee: true)
User::SetDiscordRoles.defer(user)
User::SetDiscourseGroups.defer(user)
end
end
2 changes: 1 addition & 1 deletion app/commands/user/link_with_bootcamp_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def call

return unless bootcamp_data.paid?

user.update!(bootcamp_attendee: true)
User::BecomeBootcampAttendee.(user)
end

memoize
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/bootcamp_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ def stripe_session_status
access_code: SecureRandom.hex(8)
)
if current_user
current_user.update!(bootcamp_attendee: true)
User::BecomeBootcampAttendee.(current_user)
else
user = User.find_by(email: @bootcamp_data.email)
if user
@bootcamp_data.update(user:)
user.update!(bootcamp_attendee: true)
User::BecomeBootcampAttendee.(user)
end
end
end
Expand Down

0 comments on commit 7478efb

Please sign in to comment.