app/graphql/ibrain/auth/mutations/sign_in_mutation.rb in ibrain-auth-0.1.9 vs app/graphql/ibrain/auth/mutations/sign_in_mutation.rb in ibrain-auth-0.2.0
- old
+ new
@@ -6,10 +6,11 @@
field :token, String, null: true
field :result, Boolean, null: true
argument :username, String, description: 'Username', required: true
argument :password, String, description: 'Password', required: true
+ argument :device_token, String, description: 'Device token for notification', required: false
def resolve(args)
# TODO: define logic inside repository
repo = ::AuthRepository.new(nil, normalize_params(args))
user = repo.sign_in
@@ -22,9 +23,15 @@
warden.set_user(current_user)
current_user.jwt_token, jti = auth_headers(request, user)
current_user.jti = jti
current_user.save!
+
+ if args[:device_token].present?
+ device_token = current_user.device_tokens.find_by(token: args[:device_token])
+
+ current_user.device_tokens.create!({ token: args[:device_token] }) if device_token.blank?
+ end
context[:current_user] = current_user
OpenStruct.new(
user: user_signed_in? ? current_user : nil,