Skip to content

Commit

Permalink
Help users work through an authorization problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Apr 17, 2020
1 parent f06973c commit 3fa9659
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion slack-strava/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def handle_strava_error(e)
logger.error e
case e.message
when /Authorization Error/
dm_connect! 'There was an authorization problem. Please reconnect your Strava account'
dm_connect! 'There was an authorization problem. Make sure that you leave the "View data about your private activities" box checked when reconnecting your Strava account'
reset_access_tokens!(connected_to_strava_at: nil)
end
raise e
Expand Down
4 changes: 2 additions & 2 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
let(:authorization_error) { Strava::Errors::Fault.new(401, body: { 'message' => 'Authorization Error', 'errors' => [{ 'resource' => 'Athlete', 'field' => 'access_token', 'code' => 'invalid' }] }) }
it 'raises an exception and resets token' do
allow(user.strava_client).to receive(:paginate).and_raise authorization_error
expect(user).to receive(:dm_connect!).with('There was an authorization problem. Please reconnect your Strava account')
expect(user).to receive(:dm_connect!).with('There was an authorization problem. Make sure that you leave the "View data about your private activities" box checked when reconnecting your Strava account')
user.sync_and_brag!
expect(user.access_token).to be nil
expect(user.token_type).to be nil
Expand All @@ -121,7 +121,7 @@
let(:authorization_error) { Strava::Errors::Fault.new(401, body: { 'message' => 'Authorization Error', 'errors' => [{ 'resource' => 'AccessToken', 'field' => 'activity:read_permission', 'code' => 'missing' }] }) }
it 'raises an exception and resets token' do
allow(user.strava_client).to receive(:paginate).and_raise authorization_error
expect(user).to receive(:dm_connect!).with('There was an authorization problem. Please reconnect your Strava account')
expect(user).to receive(:dm_connect!).with('There was an authorization problem. Make sure that you leave the "View data about your private activities" box checked when reconnecting your Strava account')
user.sync_and_brag!
expect(user.access_token).to be nil
expect(user.token_type).to be nil
Expand Down

0 comments on commit 3fa9659

Please sign in to comment.