ibrain-auth 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/app/graphql/ibrain/auth/mutations/base_mutation.rb +4 -2
 - data/app/graphql/ibrain/auth/mutations/{sso_sign_in_mutation.rb → social_sign_in_mutation.rb} +2 -2
 - data/app/models/ibrain/auth/user.rb +9 -2
 - data/app/repositories/apple_repository.rb +3 -1
 - data/app/repositories/auth_repository.rb +15 -5
 - data/app/repositories/twitter_repository.rb +3 -1
 - data/lib/generators/ibrain/auth/install/install_generator.rb +1 -1
 - data/lib/ibrain/auth/version.rb +2 -2
 - data/lib/ibrain/auth_configuration.rb +0 -3
 - metadata +19 -20
 - data/app/graphql/ibrain/auth/mutations/sso_sign_up_mutation.rb +0 -57
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 6f6effd595af545581f20acbc9fd7c50c8758fdf471075a001c96cc2d6741490
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7171e0aa32520f98085c44baad66941dc5a74efecf28275dc52be6aadb2c8b01
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 838a3e121f20c914e33118a04e68017f4927a4107d7863d7b9b69e817bab43352742ccc98ed4fb22e0ee72a5282ae38243c4349aa986e11ad0bb62f33cc8394a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 39e411cf62805c44c6376bcc8152ec26121a03601e94ac444f4370059e77f7a4213965c1d3c754e83a7c9b69617b1b83030f6c269ae57350f7c0698a038483e2
         
     | 
| 
         @@ -12,8 +12,10 @@ module Ibrain::Auth::Mutations 
     | 
|
| 
       12 
12 
     | 
    
         
             
                helper_method(*helpers)
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                def ready?(args)
         
     | 
| 
       15 
     | 
    
         
            -
                   
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                  @params = ActionController::Parameters.new(
         
     | 
| 
      
 16 
     | 
    
         
            +
                    args.to_h.with_indifferent_access.transform_keys(&:underscore)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  )
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       17 
19 
     | 
    
         
             
                  @auth_resource = load_resource
         
     | 
| 
       18 
20 
     | 
    
         
             
                  true
         
     | 
| 
       19 
21 
     | 
    
         
             
                end
         
     | 
    
        data/app/graphql/ibrain/auth/mutations/{sso_sign_in_mutation.rb → social_sign_in_mutation.rb}
    RENAMED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module Ibrain::Auth::Mutations
         
     | 
| 
       4 
     | 
    
         
            -
              class  
     | 
| 
      
 4 
     | 
    
         
            +
              class SocialSignInMutation < BaseMutation
         
     | 
| 
       5 
5 
     | 
    
         
             
                field :user, Types::Objects::UserType, null: true
         
     | 
| 
       6 
6 
     | 
    
         
             
                field :token, String, null: true
         
     | 
| 
       7 
7 
     | 
    
         
             
                field :result, Boolean, null: true
         
     | 
| 
       8 
8 
     | 
    
         
             
                field :is_verified, Boolean, null: true
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
                argument :id_token, String, description: 'Id Token from  
     | 
| 
      
 10 
     | 
    
         
            +
                argument :id_token, String, description: 'Id Token from firebase', required: true
         
     | 
| 
       11 
11 
     | 
    
         
             
                argument :device_token, String, description: 'Device token for notificaiton', required: false
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                def resolve(args)
         
     | 
| 
         @@ -3,10 +3,10 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module Ibrain
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Auth
         
     | 
| 
       5 
5 
     | 
    
         
             
                class User < Ibrain::Base
         
     | 
| 
       6 
     | 
    
         
            -
                  include Devise::JWT::RevocationStrategies::JTIMatcher
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
6 
     | 
    
         
             
                  attr_accessor :jwt_token
         
     | 
| 
       9 
7 
     | 
    
         | 
| 
      
 8 
     | 
    
         
            +
                  include Devise::JWT::RevocationStrategies::JTIMatcher
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
       10 
10 
     | 
    
         
             
                  self.table_name = Ibrain::Auth::Config.user_table_name
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
                  devise :database_authenticatable, :registerable,
         
     | 
| 
         @@ -40,6 +40,13 @@ module Ibrain 
     | 
|
| 
       40 
40 
     | 
    
         
             
                        where(query).first
         
     | 
| 
       41 
41 
     | 
    
         
             
                      end
         
     | 
| 
       42 
42 
     | 
    
         
             
                    end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                    def social_find_or_initialize(params)
         
     | 
| 
      
 45 
     | 
    
         
            +
                      user = find_by(provider: params[:provider], uid: params[:uid])
         
     | 
| 
      
 46 
     | 
    
         
            +
                      return user if user.present?
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                      create!(params)
         
     | 
| 
      
 49 
     | 
    
         
            +
                    end
         
     | 
| 
       43 
50 
     | 
    
         
             
                  end
         
     | 
| 
       44 
51 
     | 
    
         
             
                end
         
     | 
| 
       45 
52 
     | 
    
         
             
              end
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            class AppleRepository < Ibrain::BaseRepository
         
     | 
| 
       2 
4 
     | 
    
         
             
              def initialize(record, params)
         
     | 
| 
       3 
5 
     | 
    
         
             
                super(nil, record)
         
     | 
| 
         @@ -5,4 +7,4 @@ class AppleRepository < Ibrain::BaseRepository 
     | 
|
| 
       5 
7 
     | 
    
         
             
                @params = params
         
     | 
| 
       6 
8 
     | 
    
         
             
                @collection = Ibrain.user_class
         
     | 
| 
       7 
9 
     | 
    
         
             
              end
         
     | 
| 
       8 
     | 
    
         
            -
            end
         
     | 
| 
      
 10 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -11,7 +11,7 @@ class AuthRepository < Ibrain::BaseRepository 
     | 
|
| 
       11 
11 
     | 
    
         
             
              end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
              def create
         
     | 
| 
       14 
     | 
    
         
            -
                user =  
     | 
| 
      
 14 
     | 
    
         
            +
                user = is_social? ? firebase_verify : collection.ibrain_find(manual_params, available_columns)
         
     | 
| 
       15 
15 
     | 
    
         
             
                user.assign_attributes(normalize_params.except(:id_token))
         
     | 
| 
       16 
16 
     | 
    
         
             
                user.save
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
         @@ -19,7 +19,7 @@ class AuthRepository < Ibrain::BaseRepository 
     | 
|
| 
       19 
19 
     | 
    
         
             
              end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
              def sign_in
         
     | 
| 
       22 
     | 
    
         
            -
                return  
     | 
| 
      
 22 
     | 
    
         
            +
                return firebase_verify if is_social?
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
                user = collection.ibrain_find(manual_params, available_columns)
         
     | 
| 
       25 
25 
     | 
    
         
             
                return unless user.try(:valid_password?, manual_params[:password])
         
     | 
| 
         @@ -57,21 +57,31 @@ class AuthRepository < Ibrain::BaseRepository 
     | 
|
| 
       57 
57 
     | 
    
         
             
                params.permit(:username, :password)
         
     | 
| 
       58 
58 
     | 
    
         
             
              end
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
       60 
     | 
    
         
            -
              def  
     | 
| 
      
 60 
     | 
    
         
            +
              def firebase_verify
         
     | 
| 
       61 
61 
     | 
    
         
             
                response = HTTParty.post(firebase_url, headers: base_headers, body: { 'idToken' => normalize_params[:id_token] }.to_json )
         
     | 
| 
       62 
62 
     | 
    
         
             
                user_information = response.try(:fetch, 'users', []).try(:at, 0)
         
     | 
| 
       63 
63 
     | 
    
         | 
| 
       64 
64 
     | 
    
         
             
                uid = user_information.try(:fetch, 'localId', nil)
         
     | 
| 
      
 65 
     | 
    
         
            +
                provider = user_information.
         
     | 
| 
      
 66 
     | 
    
         
            +
                  try(:fetch, 'providerUserInfo', []).
         
     | 
| 
      
 67 
     | 
    
         
            +
                  try(:at, 0).try(:fetch, 'providerId', '').
         
     | 
| 
      
 68 
     | 
    
         
            +
                  try(:gsub, '.com', '')
         
     | 
| 
       65 
69 
     | 
    
         
             
                raise ActiveRecord::RecordNotFound, I18n.t('ibrain.errors.account.not_found') if uid.blank?
         
     | 
| 
       66 
70 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
                collection. 
     | 
| 
      
 71 
     | 
    
         
            +
                collection.social_find_or_initialize({
         
     | 
| 
      
 72 
     | 
    
         
            +
                  uid: uid,
         
     | 
| 
      
 73 
     | 
    
         
            +
                  provider: provider,
         
     | 
| 
      
 74 
     | 
    
         
            +
                  remote_avatar_url: user_information.try(:fetch, 'photoUrl', nil),
         
     | 
| 
      
 75 
     | 
    
         
            +
                  email: user_information.try(:fetch, 'email', nil),
         
     | 
| 
      
 76 
     | 
    
         
            +
                  password: 'Eco@123456'
         
     | 
| 
      
 77 
     | 
    
         
            +
                })
         
     | 
| 
       68 
78 
     | 
    
         
             
              end
         
     | 
| 
       69 
79 
     | 
    
         | 
| 
       70 
80 
     | 
    
         
             
              def available_columns
         
     | 
| 
       71 
81 
     | 
    
         
             
                collection.column_names.select { |f| ACCOUNT_COUMNS.include?(f) }
         
     | 
| 
       72 
82 
     | 
    
         
             
              end
         
     | 
| 
       73 
83 
     | 
    
         | 
| 
       74 
     | 
    
         
            -
              def  
     | 
| 
      
 84 
     | 
    
         
            +
              def is_social?
         
     | 
| 
       75 
85 
     | 
    
         
             
                normalize_params[:id_token].present?
         
     | 
| 
       76 
86 
     | 
    
         
             
              end
         
     | 
| 
       77 
87 
     | 
    
         | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            class TwitterRepository < Ibrain::BaseRepository
         
     | 
| 
       2 
4 
     | 
    
         
             
              def initialize(record, params)
         
     | 
| 
       3 
5 
     | 
    
         
             
                super(nil, record)
         
     | 
| 
         @@ -5,4 +7,4 @@ class TwitterRepository < Ibrain::BaseRepository 
     | 
|
| 
       5 
7 
     | 
    
         
             
                @params = params
         
     | 
| 
       6 
8 
     | 
    
         
             
                @collection = Ibrain.user_class
         
     | 
| 
       7 
9 
     | 
    
         
             
              end
         
     | 
| 
       8 
     | 
    
         
            -
            end
         
     | 
| 
      
 10 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -18,7 +18,7 @@ module Ibrain 
     | 
|
| 
       18 
18 
     | 
    
         
             
                    template 'config/initializers/devise.rb.tt', 'config/initializers/devise.rb', { skip: true }
         
     | 
| 
       19 
19 
     | 
    
         
             
                    template 'config/initializers/ibrain_auth.rb.tt', 'config/initializers/ibrain_auth.rb', { skip: true }
         
     | 
| 
       20 
20 
     | 
    
         
             
                    template 'config/initializers/ibrain_jwt.rb.tt', 'config/initializers/ibrain_jwt.rb', { skip: true }
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
       22 
22 
     | 
    
         
             
                    if options[:with_social]
         
     | 
| 
       23 
23 
     | 
    
         
             
                      template 'config/initializers/omniauth.rb.tt', 'config/initializers/omniauth.rb', { skip: true }
         
     | 
| 
       24 
24 
     | 
    
         
             
                    end
         
     | 
    
        data/lib/ibrain/auth/version.rb
    CHANGED
    
    | 
         @@ -4,14 +4,14 @@ module Ibrain 
     | 
|
| 
       4 
4 
     | 
    
         
             
              # frozen_string_literal: true
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
              module Auth
         
     | 
| 
       7 
     | 
    
         
            -
                VERSION = '0.2. 
     | 
| 
      
 7 
     | 
    
         
            +
                VERSION = '0.2.6'
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                def self.ibrain_auth_version
         
     | 
| 
       10 
10 
     | 
    
         
             
                  VERSION
         
     | 
| 
       11 
11 
     | 
    
         
             
                end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                def self.previous_ibrain_auth_minor_version
         
     | 
| 
       14 
     | 
    
         
            -
                  '0.2. 
     | 
| 
      
 14 
     | 
    
         
            +
                  '0.2.5'
         
     | 
| 
       15 
15 
     | 
    
         
             
                end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                def self.ibrain_auth_gem_version
         
     | 
| 
         @@ -1,8 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            require_relative '../../app/graphql/ibrain/auth/types/input/sign_in_input.rb'
         
     | 
| 
       4 
     | 
    
         
            -
            require_relative '../../app/graphql/ibrain/auth/types/input/sign_up_input.rb'
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
3 
     | 
    
         
             
            module Ibrain
         
     | 
| 
       7 
4 
     | 
    
         
             
              class AuthConfiguration < Preferences::Configuration
         
     | 
| 
       8 
5 
     | 
    
         
             
                preference :api_version, :string, default: 'v1'
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,17 +1,17 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: ibrain-auth
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.6
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Tai Nguyen Van
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2022-09- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-09-30 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
     | 
    
         
            -
              name: devise
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: devise-encryptable
         
     | 
| 
       15 
15 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
17 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -25,7 +25,7 @@ dependencies: 
     | 
|
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
26 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
     | 
    
         
            -
              name: devise- 
     | 
| 
      
 28 
     | 
    
         
            +
              name: devise-i18n
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
31 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -39,7 +39,7 @@ dependencies: 
     | 
|
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
40 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       41 
41 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
     | 
    
         
            -
              name: devise- 
     | 
| 
      
 42 
     | 
    
         
            +
              name: devise-jwt
         
     | 
| 
       43 
43 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       44 
44 
     | 
    
         
             
                requirements:
         
     | 
| 
       45 
45 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -53,7 +53,7 @@ dependencies: 
     | 
|
| 
       53 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
54 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       55 
55 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       56 
     | 
    
         
            -
              name:  
     | 
| 
      
 56 
     | 
    
         
            +
              name: ibrain-core
         
     | 
| 
       57 
57 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       58 
58 
     | 
    
         
             
                requirements:
         
     | 
| 
       59 
59 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -67,7 +67,7 @@ dependencies: 
     | 
|
| 
       67 
67 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       68 
68 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       69 
69 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       70 
     | 
    
         
            -
              name:  
     | 
| 
      
 70 
     | 
    
         
            +
              name: rails
         
     | 
| 
       71 
71 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       72 
72 
     | 
    
         
             
                requirements:
         
     | 
| 
       73 
73 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -81,19 +81,19 @@ dependencies: 
     | 
|
| 
       81 
81 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       82 
82 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       83 
83 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       84 
     | 
    
         
            -
              name:  
     | 
| 
      
 84 
     | 
    
         
            +
              name: warden-jwt_auth
         
     | 
| 
       85 
85 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       86 
86 
     | 
    
         
             
                requirements:
         
     | 
| 
       87 
     | 
    
         
            -
                - -  
     | 
| 
      
 87 
     | 
    
         
            +
                - - '='
         
     | 
| 
       88 
88 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       89 
     | 
    
         
            -
                    version:  
     | 
| 
      
 89 
     | 
    
         
            +
                    version: 0.6.0
         
     | 
| 
       90 
90 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       91 
91 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       92 
92 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       93 
93 
     | 
    
         
             
                requirements:
         
     | 
| 
       94 
     | 
    
         
            -
                - -  
     | 
| 
      
 94 
     | 
    
         
            +
                - - '='
         
     | 
| 
       95 
95 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       96 
     | 
    
         
            -
                    version:  
     | 
| 
      
 96 
     | 
    
         
            +
                    version: 0.6.0
         
     | 
| 
       97 
97 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       98 
98 
     | 
    
         
             
              name: omniauth
         
     | 
| 
       99 
99 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -109,7 +109,7 @@ dependencies: 
     | 
|
| 
       109 
109 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       110 
110 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       111 
111 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       112 
     | 
    
         
            -
              name: omniauth- 
     | 
| 
      
 112 
     | 
    
         
            +
              name: omniauth-apple
         
     | 
| 
       113 
113 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       114 
114 
     | 
    
         
             
                requirements:
         
     | 
| 
       115 
115 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -123,7 +123,7 @@ dependencies: 
     | 
|
| 
       123 
123 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       124 
124 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       125 
125 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       126 
     | 
    
         
            -
              name: omniauth- 
     | 
| 
      
 126 
     | 
    
         
            +
              name: omniauth-facebook
         
     | 
| 
       127 
127 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       128 
128 
     | 
    
         
             
                requirements:
         
     | 
| 
       129 
129 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -137,7 +137,7 @@ dependencies: 
     | 
|
| 
       137 
137 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       138 
138 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       139 
139 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       140 
     | 
    
         
            -
              name: omniauth- 
     | 
| 
      
 140 
     | 
    
         
            +
              name: omniauth-google-oauth2
         
     | 
| 
       141 
141 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       142 
142 
     | 
    
         
             
                requirements:
         
     | 
| 
       143 
143 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -151,7 +151,7 @@ dependencies: 
     | 
|
| 
       151 
151 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       152 
152 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       153 
153 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       154 
     | 
    
         
            -
              name: omniauth- 
     | 
| 
      
 154 
     | 
    
         
            +
              name: omniauth-line
         
     | 
| 
       155 
155 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       156 
156 
     | 
    
         
             
                requirements:
         
     | 
| 
       157 
157 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -165,7 +165,7 @@ dependencies: 
     | 
|
| 
       165 
165 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       166 
166 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       167 
167 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       168 
     | 
    
         
            -
              name: omniauth- 
     | 
| 
      
 168 
     | 
    
         
            +
              name: omniauth-twitter
         
     | 
| 
       169 
169 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       170 
170 
     | 
    
         
             
                requirements:
         
     | 
| 
       171 
171 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -197,8 +197,7 @@ files: 
     | 
|
| 
       197 
197 
     | 
    
         
             
            - app/graphql/ibrain/auth/mutations/sign_in_mutation.rb
         
     | 
| 
       198 
198 
     | 
    
         
             
            - app/graphql/ibrain/auth/mutations/sign_out_mutation.rb
         
     | 
| 
       199 
199 
     | 
    
         
             
            - app/graphql/ibrain/auth/mutations/sign_up_mutation.rb
         
     | 
| 
       200 
     | 
    
         
            -
            - app/graphql/ibrain/auth/mutations/ 
     | 
| 
       201 
     | 
    
         
            -
            - app/graphql/ibrain/auth/mutations/sso_sign_up_mutation.rb
         
     | 
| 
      
 200 
     | 
    
         
            +
            - app/graphql/ibrain/auth/mutations/social_sign_in_mutation.rb
         
     | 
| 
       202 
201 
     | 
    
         
             
            - app/graphql/ibrain/auth/types/input/sign_in_input.rb
         
     | 
| 
       203 
202 
     | 
    
         
             
            - app/graphql/ibrain/auth/types/input/sign_up_input.rb
         
     | 
| 
       204 
203 
     | 
    
         
             
            - app/models/ibrain/auth/user.rb
         
     | 
| 
         @@ -246,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       246 
245 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       247 
246 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       248 
247 
     | 
    
         
             
            requirements: []
         
     | 
| 
       249 
     | 
    
         
            -
            rubygems_version: 3.3. 
     | 
| 
      
 248 
     | 
    
         
            +
            rubygems_version: 3.3.7
         
     | 
| 
       250 
249 
     | 
    
         
             
            signing_key:
         
     | 
| 
       251 
250 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       252 
251 
     | 
    
         
             
            summary: Its Auth is an sso authen gem for Ruby on Rails.
         
     | 
| 
         @@ -1,57 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            module Ibrain::Auth::Mutations
         
     | 
| 
       4 
     | 
    
         
            -
              class SsoSignUpMutation < BaseMutation
         
     | 
| 
       5 
     | 
    
         
            -
                field :user, Types::Objects::UserType, null: true
         
     | 
| 
       6 
     | 
    
         
            -
                field :token, String, null: true
         
     | 
| 
       7 
     | 
    
         
            -
                field :result, Boolean, null: true
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                argument :id_token, String, description: 'Id Token from SSO', required: true
         
     | 
| 
       10 
     | 
    
         
            -
                argument :user, Ibrain::Auth::Config.sign_up_input, required: true
         
     | 
| 
       11 
     | 
    
         
            -
                argument :device_token, String, description: 'Device token for notificaiton', required: false
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                def resolve(args)
         
     | 
| 
       14 
     | 
    
         
            -
                  # TODO: define logic inside repository
         
     | 
| 
       15 
     | 
    
         
            -
                  repo = ::AuthRepository.new(nil, normalize_params(args))
         
     | 
| 
       16 
     | 
    
         
            -
                  user = repo.sign_up
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                  return OpenStruct.new({ user: nil, token: nil, result: false, is_verified: false }) if user.blank?
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                  sign_in(resource_name, user)
         
     | 
| 
       21 
     | 
    
         
            -
                  @current_user = warden.authenticate!(auth_options)
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                  warden.set_user(current_user)
         
     | 
| 
       24 
     | 
    
         
            -
                  current_user.jwt_token, jti = auth_headers(request, user)
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                  current_user.jti = jti
         
     | 
| 
       27 
     | 
    
         
            -
                  current_user.save!
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                  if args[:device_token].present?
         
     | 
| 
       30 
     | 
    
         
            -
                    device_token = current_user.device_tokens.find_by(token: args[:device_token])
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                    current_user.device_tokens.create!({ token: args[:device_token] }) if device_token.blank?
         
     | 
| 
       33 
     | 
    
         
            -
                  end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                  context[:current_user] = current_user
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                  OpenStruct.new(
         
     | 
| 
       38 
     | 
    
         
            -
                    user: user_signed_in? ? current_user : nil,
         
     | 
| 
       39 
     | 
    
         
            -
                    token: current_user.try(:jwt_token),
         
     | 
| 
       40 
     | 
    
         
            -
                    result: user_signed_in?,
         
     | 
| 
       41 
     | 
    
         
            -
                    is_verified: true
         
     | 
| 
       42 
     | 
    
         
            -
                  )
         
     | 
| 
       43 
     | 
    
         
            -
                end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                private
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
                def normalize_params(args)
         
     | 
| 
       48 
     | 
    
         
            -
                  ActionController::Parameters.new(args.as_json)
         
     | 
| 
       49 
     | 
    
         
            -
                rescue StandardError
         
     | 
| 
       50 
     | 
    
         
            -
                  ActionController::Parameters.new({})
         
     | 
| 
       51 
     | 
    
         
            -
                end
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                def auth_options
         
     | 
| 
       54 
     | 
    
         
            -
                  { scope: resource_name }
         
     | 
| 
       55 
     | 
    
         
            -
                end
         
     | 
| 
       56 
     | 
    
         
            -
              end
         
     | 
| 
       57 
     | 
    
         
            -
            end
         
     |