Skip to content

Commit 47cb54b

Browse files
handle already existing team membership
1 parent db07554 commit 47cb54b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

packages/hacker_dashboard_portal/app/controllers/hacker_dashboard_portal/hackathon/team_memberships_controller.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ class HackerDashboardPortal::Hackathon::TeamMembershipsController < ::Hackathon:
88

99
def present_scoped_entity? = true
1010

11+
def new
12+
authorize_current! resource_class
13+
14+
unless current_user.team.nil?
15+
redirect_to root_path
16+
return
17+
end
18+
19+
super
20+
end
21+
1122
private
1223

1324
def resource_params

packages/hacker_dashboard_portal/app/policies/hacker_dashboard_portal/hackathon/team_membership_policy.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ class HackerDashboardPortal::Hackathon::TeamMembershipPolicy < ::Hackathon::Team
22
authorize :invitation, allow_nil: true
33
# Core attributes
44

5+
def new?
6+
true
7+
end
8+
59
def create?
610
user.team.nil?
711
end

0 commit comments

Comments
 (0)