ibrain-auth 0.1.2 → 0.1.3
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/sign_in_mutation.rb +8 -8
- data/config/locales/en.yml +2 -1
- data/config/locales/jp.yml +2 -1
- data/config/locales/vi.yml +2 -1
- data/lib/generators/ibrain/auth/install/templates/config/initializers/ibrain_jwt.rb.tt +8 -0
- data/lib/ibrain/auth/failure_app.rb +27 -0
- data/lib/ibrain/auth/version.rb +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8beb80a1714ee5b7c3ec02814d39e2ae186648b42d9a2bc825882203275f051d
|
4
|
+
data.tar.gz: d1d6c607cb8260a4d8f1fa6b36f4098ed98a19d237f48a4191f6c1a0c00d49be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 917de92b8fd15175a62b1e4bc5098ac6529d01e3dceb611c951c00f79bd81054f6febecb25b5b29c3b6efede2825adcbc4025f049f718ebe1d6431645e221a29
|
7
|
+
data.tar.gz: 7d7bde52fb6a18262a88fa4fe2b3b933f1f8e054ce63ee89ea1e87a99316ef832dfa40f30e74324142f5e8d3830c9997ef169176ddffed1ce97fe55d7d29ff94
|
@@ -14,16 +14,16 @@ module Ibrain::Auth::Mutations
|
|
14
14
|
repo = ::AuthRepository.new(nil, normalize_params(args))
|
15
15
|
user = repo.sign_in
|
16
16
|
|
17
|
-
if user.
|
18
|
-
sign_in(resource_name, user)
|
19
|
-
@current_user = warden.authenticate!(auth_options)
|
17
|
+
raise ActionController::InvalidAuthenticityToken, I18n.t('ibrain.errors.account.incorrect') if user.blank?
|
20
18
|
|
21
|
-
|
22
|
-
|
19
|
+
sign_in(resource_name, user)
|
20
|
+
@current_user = warden.authenticate!(auth_options)
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
warden.set_user(current_user)
|
23
|
+
current_user.jwt_token, jti = auth_headers(request, user)
|
24
|
+
|
25
|
+
current_user.jti = jti
|
26
|
+
current_user.save!
|
27
27
|
|
28
28
|
OpenStruct.new(
|
29
29
|
user: user_signed_in? ? current_user : nil,
|
data/config/locales/en.yml
CHANGED
data/config/locales/jp.yml
CHANGED
data/config/locales/vi.yml
CHANGED
@@ -1,5 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ibrain/auth/failure_app'
|
4
|
+
|
1
5
|
# ==> Configuration for jwt
|
2
6
|
Devise.jwt do |jwt|
|
3
7
|
jwt.secret = ENV.fetch('JWT_SECRET_KEY', Ibrain::Auth::Config.jwt_secret_key) # Rails.application.credentials.secret_key_base
|
4
8
|
jwt.expiration_time = 3600 * 24 * 30 # 30day
|
9
|
+
end
|
10
|
+
|
11
|
+
Devise.warden do |manager|
|
12
|
+
manager.failure_app = Ibrain::Auth::FailureApp
|
5
13
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Ibrain::Auth::FailureApp < Devise::FailureApp
|
4
|
+
include ActionController::Helpers
|
5
|
+
|
6
|
+
def respond
|
7
|
+
json_error_response
|
8
|
+
end
|
9
|
+
|
10
|
+
def json_error_response
|
11
|
+
self.status = 401
|
12
|
+
self.content_type = "application/json"
|
13
|
+
self.response_body = {
|
14
|
+
errors: [{
|
15
|
+
message: i18n_message,
|
16
|
+
extensions: {
|
17
|
+
code: 401,
|
18
|
+
exception: {
|
19
|
+
stacktrace: []
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}],
|
23
|
+
message: i18n_message,
|
24
|
+
data: nil
|
25
|
+
}.to_json
|
26
|
+
end
|
27
|
+
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.3'
|
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.2'
|
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.3
|
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-05 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.1.
|
75
|
+
version: 0.1.9
|
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.1.
|
82
|
+
version: 0.1.9
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- lib/ibrain/auth.rb
|
149
149
|
- lib/ibrain/auth/devise.rb
|
150
150
|
- lib/ibrain/auth/engine.rb
|
151
|
+
- lib/ibrain/auth/failure_app.rb
|
151
152
|
- lib/ibrain/auth/version.rb
|
152
153
|
- lib/ibrain/auth_configuration.rb
|
153
154
|
- lib/ibrain/authentication_helpers.rb
|