Skip to content

Commit

Permalink
Merge pull request #18 from o2web/bugfix-current-user-signin
Browse files Browse the repository at this point in the history
Add set_current_user_token at sign_in
  • Loading branch information
bricesanchez authored Mar 14, 2019
2 parents 7fa8515 + 1b4217c commit 7fa09f3
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(user)
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(user)
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 7fa09f3

Please sign in to comment.