Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions lib/graphql_devise/types/credential_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
module GraphqlDevise
module Types
class CredentialType < BaseType
field :access_token, String, null: false
field :uid, String, null: false
field :token_type, String, null: false
field :client, String, null: false
field :expiry, Int, null: false
field :access_token, String, null: false
field :uid, String, null: false
field :token_type, String, null: false
field :client, String, null: false
field :expiry, Int, null: false
field :authorization, String, null: false

def access_token
object[DeviseTokenAuth.headers_names[:"access-token"]]
Expand All @@ -28,6 +29,10 @@ def client
def expiry
object[DeviseTokenAuth.headers_names[:expiry]]
end

def authorization
object[DeviseTokenAuth.headers_names[:authorization]]
end
end
end
end
13 changes: 7 additions & 6 deletions spec/requests/mutations/login_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
password: "#{password}"
) {
user { email name signInCount }
credentials { accessToken uid tokenType client expiry }
credentials { accessToken uid tokenType client expiry authorization }
}
}
GRAPHQL
Expand All @@ -34,11 +34,12 @@
expect(json_response[:data][:userLogin]).to match(
user: { email: user.email, name: user.name, signInCount: 1 },
credentials: {
accessToken: response.headers['access-token'],
uid: response.headers['uid'],
tokenType: response.headers['token-type'],
client: response.headers['client'],
expiry: response.headers['expiry'].to_i
accessToken: response.headers['access-token'],
uid: response.headers['uid'],
tokenType: response.headers['token-type'],
client: response.headers['client'],
expiry: response.headers['expiry'].to_i,
authorization: response.headers['Authorization']
}
)
expect(json_response[:errors]).to be_nil
Expand Down