Skip to content

Commit

Permalink
Add set_current_user_token at sign_in
Browse files Browse the repository at this point in the history
  • Loading branch information
bricesanchez committed Mar 14, 2019
1 parent 7fa8515 commit 8a2b3e2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/graphql/mutations/auth/sign_in.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def resolve(email:, password:, remember_me:)

if valid_sign_in
generate_access_token(user, response)
set_current_user_token(user, context)
remember_me ? set_refresh_token(user, response) : delete_refresh_token(user)

{
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/graphql/token_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def set_refresh_token(user, response)
response.set_header 'RefreshToken', refresh_token
end

def set_current_user_token(user, context)
context[:current_user] = user
end

def delete_refresh_token(user)
user.update_column :refresh_token, nil if user.refresh_token.present?
end
Expand Down
2 changes: 1 addition & 1 deletion lib/graphql-auth/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module GraphQL
module Auth
VERSION = '0.4.0'
VERSION = '0.4.1'
end
end

0 comments on commit 8a2b3e2

Please sign in to comment.