Skip to content

Commit 0b37d1f

Browse files
authored
Initial v2 subscription fix (#1152)
1 parent e25ce03 commit 0b37d1f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lib/travis/api/app/endpoint/authorization.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ class Authorization < Endpoint
134134
def update_first_login(user)
135135
unless user.first_logged_in_at
136136
user.update_attributes(first_logged_in_at: Time.now)
137-
user.create_initial_subscription unless Travis.config.org?
138137
end
139138
end
140139

@@ -179,6 +178,7 @@ def handshake
179178
token = generate_token(user: user, app_id: 0)
180179
payload = params[:state].split(":::", 2)[1]
181180
update_first_login(user)
181+
user.create_initial_subscription
182182
yield serialize_user(user), token, payload
183183
else
184184
values[:state] = create_state
@@ -213,6 +213,7 @@ def vcs_handshake
213213

214214
user = User.find(vcs_data['user']['id'])
215215
update_first_login(user)
216+
user.create_initial_subscription
216217
yield serialize_user(user), vcs_data['token'], payload(params[:provider])
217218
else
218219
state = vcs_create_state(params[:origin] || params[:redirect_uri])

lib/travis/api/v3/models/user.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ def github?
8484
end
8585

8686
def create_initial_subscription
87+
return if Travis.config.org?
88+
8789
client = BillingClient.new(id)
8890
client.create_initial_v2_subscription
8991
end

lib/travis/model/user.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ def github?
171171
end
172172

173173
def create_initial_subscription
174+
return if Travis.config.org?
175+
174176
client = Travis::API::V3::BillingClient.new(id)
175177
client.create_initial_v2_subscription
176178
end

0 commit comments

Comments
 (0)