Skip to content

Commit 72faadb

Browse files
committed
Only update roles in Immediate Onboarding branch
1 parent f2c22bd commit 72faadb

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

app/services/school_verification_service.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ def verify(token: nil)
1212
School.transaction do
1313
school.verify!
1414

15-
creator_id = school.creator_id
16-
Role.owner.find_or_create_by!(user_id: creator_id, school:)
17-
Role.teacher.find_or_create_by!(user_id: creator_id, school:)
18-
19-
# TODO: Remove this line, once the feature flag is retired
20-
success = FeatureFlags.immediate_school_onboarding? || SchoolOnboardingService.new(school).onboard(token: token)
15+
if FeatureFlags.immediate_school_onboarding?
16+
# For backwards compatibility with pre-Immediate Onboarding unverified schools, we need to create the roles
17+
# if they don't exist - this didn't happen at the time the school was created.
18+
creator_id = school.creator_id
19+
Role.owner.find_or_create_by!(user_id: creator_id, school:)
20+
Role.teacher.find_or_create_by!(user_id: creator_id, school:)
21+
success = true
22+
else
23+
success = SchoolOnboardingService.new(school).onboard(token: token)
24+
end
2125

2226
# TODO: Remove this line, once the feature flag is retired
2327
raise ActiveRecord::Rollback unless success

0 commit comments

Comments
 (0)