Skip to content

Commit

Permalink
Moves exception raising inside TokenManager
Browse files Browse the repository at this point in the history
  • Loading branch information
plandino committed Jul 27, 2017
1 parent 798e38b commit 0b255b9
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 6 deletions.
2 changes: 0 additions & 2 deletions lib/wor/authentication/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ def decoded_token
@decoded_token ||= Wor::Authentication::TokenManager.new(
token_key
).decode(authentication_token)
return @decoded_token if @decoded_token.present?
raise Wor::Authentication::Exceptions::InvalidAuthorizationToken
end

def new_token_expiration_date
Expand Down
2 changes: 1 addition & 1 deletion lib/wor/authentication/token_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def decode(token)
payload = JWT.decode(token, @key)[0]
Wor::Authentication::DecodedToken.new(payload)
rescue
nil
raise Wor::Authentication::Exceptions::InvalidAuthorizationToken
end
end
end
Expand Down
3 changes: 0 additions & 3 deletions spec/wor/authentication/controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
require 'spec_helper'
require 'spy'

describe ApplicationController, type: :controller do

describe '#authenticate_request' do

subject { described_class.new }

context 'without Authorization Header' do
Expand Down

0 comments on commit 0b255b9

Please sign in to comment.