ibrain-auth 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30ccc8647d90b04b385f7bb63e24dbdecb1365d6c3db4a4bb187a19b7ab476c3
|
4
|
+
data.tar.gz: 25265497ddf2b02cb26b23c1d509749a54947356cb37a7c2179f1cf68efa5639
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9df833ba495a2139dd9b23f6012ca73ff040e2b4cfcaf7f03efa0dd3be78310bacb1c9e6d88800762c39c053c905bbc9ad4095a3622d8497f2bc867c114b1dc6
|
7
|
+
data.tar.gz: ca80d2bb38a7a63247cda64558876af54869a100025261b36eafc8ab93f9888971935fca14400aede6fc9ae8a649bedf6bdf994838ec267c22ca2fde415fd24a
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ibrain::Auth::Mutations
|
4
|
+
class SignInMutation < 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
|
+
|
11
|
+
def resolve(args)
|
12
|
+
# TODO: define logic inside repository
|
13
|
+
repo = ::AuthRepository.new(nil, normalize_params(args))
|
14
|
+
user = repo.sign_in
|
15
|
+
|
16
|
+
raise ActionController::InvalidAuthenticityToken, I18n.t('ibrain.errors.account.incorrect') if user.blank?
|
17
|
+
|
18
|
+
sign_in(resource_name, user)
|
19
|
+
@current_user = warden.authenticate!(auth_options)
|
20
|
+
|
21
|
+
warden.set_user(current_user)
|
22
|
+
current_user.jwt_token, jti = auth_headers(request, user)
|
23
|
+
|
24
|
+
current_user.jti = jti
|
25
|
+
current_user.save!
|
26
|
+
|
27
|
+
context[:current_user] = current_user
|
28
|
+
|
29
|
+
OpenStruct.new(
|
30
|
+
user: user_signed_in? ? current_user : nil,
|
31
|
+
token: current_user.try(:jwt_token),
|
32
|
+
result: user_signed_in?
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def normalize_params(args)
|
39
|
+
ActionController::Parameters.new({ auth: args })
|
40
|
+
end
|
41
|
+
|
42
|
+
def auth_options
|
43
|
+
{ scope: resource_name }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
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.1.
|
7
|
+
VERSION = '0.1.5'
|
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.1.
|
14
|
+
'0.1.4'
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.ibrain_auth_gem_version
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibrain-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
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-01-
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.2.
|
75
|
+
version: 0.2.4
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.2.
|
82
|
+
version: 0.2.4
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- app/graphql/ibrain/auth/mutations/base_mutation.rb
|
133
133
|
- app/graphql/ibrain/auth/mutations/sign_in_mutation.rb
|
134
134
|
- app/graphql/ibrain/auth/mutations/sign_out_mutation.rb
|
135
|
+
- app/graphql/ibrain/auth/mutations/sso_sign_in_mutation.rb
|
135
136
|
- app/models/ibrain/auth/user.rb
|
136
137
|
- app/repositories/auth_repository.rb
|
137
138
|
- config/initializers/devise.rb
|