ibrain-auth 0.3.3 → 0.3.5
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 +5 -0
- data/app/graphql/ibrain/auth/mutations/social_sign_in_mutation.rb +13 -9
- data/app/models/ibrain/auth/user.rb +10 -2
- data/config/locales/en.yml +2 -1
- data/config/locales/{jp.yml → ja.yml} +3 -2
- data/config/locales/vi.yml +2 -1
- data/config/routes.rb +1 -1
- data/lib/ibrain/auth/version.rb +1 -5
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 131a35d1f5296b7ea35e0b3981136e836c2f0a7ad0fea72c9c2f3da8d0b7dc2a
|
4
|
+
data.tar.gz: cd4eb62df7abd2ed22446dea6c45560f0aeb3c7ae19275698e8b874203fa4a32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf1cd065dcc63b70d4b78dbb1f6f7f0c780cfda32879cc71cadc158eabb27db19f60e6d9c9e7c88adb5666df0381d03b06700ab1715e666619a10f5409e47537
|
7
|
+
data.tar.gz: c31acc36e489945bc95028da8887cc7199a0c4b12caf22b3d8edbb1174a4de3962ec65e72d8a82a61f39b8c24541db2fe57ca609a44b29c2aff2c566772d9809
|
@@ -12,6 +12,11 @@ module Ibrain::Auth::Mutations
|
|
12
12
|
def resolve(_args)
|
13
13
|
raise ActionController::InvalidAuthenticityToken, I18n.t('ibrain.errors.account.incorrect') if auth_resource.blank?
|
14
14
|
|
15
|
+
if !auth_resource.try(:can_skip_confirmation?) && !auth_resource.try(:confirmed?)
|
16
|
+
raise ActionController::InvalidAuthenticityToken, I18n.t('ibrain.errors.account.not_verified')
|
17
|
+
end
|
18
|
+
|
19
|
+
auth_resource.skip_confirmation! unless auth_resource.try(:confirmed?)
|
15
20
|
sign_in(resource_name, auth_resource)
|
16
21
|
@current_user = warden.authenticate!(auth_options)
|
17
22
|
|
@@ -11,18 +11,14 @@ module Ibrain::Auth::Mutations
|
|
11
11
|
argument :device_token, String, description: 'Device token for notificaiton', required: false
|
12
12
|
|
13
13
|
def resolve(args)
|
14
|
-
|
15
|
-
repo = ::AuthRepository.new(nil, normalize_params(args))
|
16
|
-
user = repo.sign_in
|
14
|
+
return OpenStruct.new({ user: nil, token: nil, result: false, is_verified: false }) if auth_resource.blank?
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
sign_in(resource_name, user)
|
16
|
+
auth_resource.skip_confirmation! unless auth_resource.try(:confirmed?)
|
17
|
+
sign_in(resource_name, auth_resource)
|
21
18
|
@current_user = warden.authenticate!(auth_options)
|
22
19
|
|
23
20
|
warden.set_user(current_user)
|
24
|
-
current_user.jwt_token, jti = auth_headers(request,
|
25
|
-
|
21
|
+
current_user.jwt_token, jti = auth_headers(request, auth_resource)
|
26
22
|
current_user.jti = jti
|
27
23
|
current_user.save!
|
28
24
|
|
@@ -44,7 +40,7 @@ module Ibrain::Auth::Mutations
|
|
44
40
|
|
45
41
|
private
|
46
42
|
|
47
|
-
def
|
43
|
+
def normalize_parameters(args)
|
48
44
|
ActionController::Parameters.new(args.as_json)
|
49
45
|
rescue StandardError
|
50
46
|
ActionController::Parameters.new({})
|
@@ -53,5 +49,13 @@ module Ibrain::Auth::Mutations
|
|
53
49
|
def auth_options
|
54
50
|
{ scope: resource_name }
|
55
51
|
end
|
52
|
+
|
53
|
+
def repo
|
54
|
+
::AuthRepository.new(nil, normalize_parameters)
|
55
|
+
end
|
56
|
+
|
57
|
+
def load_resource
|
58
|
+
repo.sign_in
|
59
|
+
end
|
56
60
|
end
|
57
61
|
end
|
@@ -6,7 +6,8 @@ module Ibrain
|
|
6
6
|
attr_accessor :jwt_token
|
7
7
|
|
8
8
|
include Devise::JWT::RevocationStrategies::JTIMatcher
|
9
|
-
|
9
|
+
|
10
|
+
self.abstract_class = true
|
10
11
|
self.table_name = Ibrain::Auth::Config.user_table_name
|
11
12
|
|
12
13
|
devise :database_authenticatable, :registerable, :confirmable,
|
@@ -30,6 +31,10 @@ module Ibrain
|
|
30
31
|
super.merge({ 'role' => role }, hasura_keys)
|
31
32
|
end
|
32
33
|
|
34
|
+
def can_skip_confirmation?
|
35
|
+
try(:is_admin?) || email.blank?
|
36
|
+
end
|
37
|
+
|
33
38
|
class << self
|
34
39
|
def ibrain_find(params, available_columns)
|
35
40
|
matched_value = params[:username] || params[:email]
|
@@ -53,11 +58,14 @@ module Ibrain
|
|
53
58
|
end
|
54
59
|
|
55
60
|
def create_with_line!(params)
|
56
|
-
created!({
|
61
|
+
user = created!({
|
57
62
|
uid: params['uid'],
|
58
63
|
provider: 'line',
|
59
64
|
remote_avatar_url: params['info']['image']
|
60
65
|
})
|
66
|
+
|
67
|
+
user.skip_confirmation! unless user&.confirmed?
|
68
|
+
user
|
61
69
|
end
|
62
70
|
end
|
63
71
|
end
|
data/config/locales/en.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
ja:
|
2
2
|
ibrain:
|
3
3
|
system:
|
4
4
|
message:
|
@@ -10,4 +10,5 @@ jp:
|
|
10
10
|
expired_session: ログインセッションが期限切れになりました。
|
11
11
|
account:
|
12
12
|
not_found: アカウントが見つかりません
|
13
|
-
incorrect: ユーザー名またはパスワードが正しくありません!
|
13
|
+
incorrect: ユーザー名またはパスワードが正しくありません!
|
14
|
+
not_verified: ログインする前にアカウントを確認してください
|
data/config/locales/vi.yml
CHANGED
@@ -10,4 +10,5 @@ vi:
|
|
10
10
|
expired_session: Phiên đăng nhập đã hết hạn.
|
11
11
|
account:
|
12
12
|
not_found: Không tìm thấy tài khoản
|
13
|
-
incorrect: Tài khoản hoặc mật khẩu không chính xác!
|
13
|
+
incorrect: Tài khoản hoặc mật khẩu không chính xác!
|
14
|
+
not_verified: Vui lòng xác minh tài khoản của bạn trước khi đăng nhập
|
data/config/routes.rb
CHANGED
@@ -8,5 +8,5 @@ Ibrain::Auth::Engine.routes.draw do
|
|
8
8
|
path: "api/#{Ibrain::Config.api_version}/users",
|
9
9
|
defaults: { format: :json }
|
10
10
|
|
11
|
-
|
11
|
+
match "api/#{Ibrain::Config.api_version}/users/callback", to: 'sessions#callback', via: 'get'
|
12
12
|
end
|
data/lib/ibrain/auth/version.rb
CHANGED
@@ -4,16 +4,12 @@ module Ibrain
|
|
4
4
|
# frozen_string_literal: true
|
5
5
|
|
6
6
|
module Auth
|
7
|
-
VERSION = '0.3.
|
7
|
+
VERSION = '0.3.5'
|
8
8
|
|
9
9
|
def self.ibrain_auth_version
|
10
10
|
VERSION
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.previous_ibrain_auth_minor_version
|
14
|
-
'0.3.2'
|
15
|
-
end
|
16
|
-
|
17
13
|
def self.ibrain_auth_gem_version
|
18
14
|
Gem::Version.new(ibrain_auth_version)
|
19
15
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibrain-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.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-
|
11
|
+
date: 2022-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: devise
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: devise-encryptable
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -208,7 +222,7 @@ files:
|
|
208
222
|
- app/repositories/line_repository.rb
|
209
223
|
- config/initializers/devise.rb
|
210
224
|
- config/locales/en.yml
|
211
|
-
- config/locales/
|
225
|
+
- config/locales/ja.yml
|
212
226
|
- config/locales/vi.yml
|
213
227
|
- config/routes.rb
|
214
228
|
- lib/generators/ibrain/auth/install/install_generator.rb
|