ibrain-auth 0.3.2 → 0.3.4
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 +1 -1
- data/app/models/ibrain/auth/user.rb +8 -1
- 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 +3 -2
- data/lib/ibrain/auth/version.rb +2 -2
- data/lib/ibrain/auth.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c770305135ae26248db7449d6aaa479a77e15c3935888096eb50eff4baf8284
|
4
|
+
data.tar.gz: d3193ce7139a9325aa51f3a4da3af93bee63ae057553a5b4dbb6eb940f2863e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f5861b311f1f4dd0e97d652b8f444215a28eac88445c3d0400140b15b1f83387061eee91031c42f1b2dc061360e914c2270debe237d85753b880cadddd4f384
|
7
|
+
data.tar.gz: 2391871bbe3b6bdfdefabd14b09f97e167fa1928818afa8ddfc3024e178d842529cade266f883b2dc7dae7c20a4270af588f9e189b885ee2559d43d26795917a
|
@@ -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
|
|
@@ -17,12 +17,12 @@ module Ibrain::Auth::Mutations
|
|
17
17
|
|
18
18
|
return OpenStruct.new({ user: nil, token: nil, result: false, is_verified: false }) if user.blank?
|
19
19
|
|
20
|
+
auth_resource.skip_confirmation! unless auth_resource.try(:confirmed?)
|
20
21
|
sign_in(resource_name, user)
|
21
22
|
@current_user = warden.authenticate!(auth_options)
|
22
23
|
|
23
24
|
warden.set_user(current_user)
|
24
25
|
current_user.jwt_token, jti = auth_headers(request, user)
|
25
|
-
|
26
26
|
current_user.jti = jti
|
27
27
|
current_user.save!
|
28
28
|
|
@@ -30,6 +30,10 @@ module Ibrain
|
|
30
30
|
super.merge({ 'role' => role }, hasura_keys)
|
31
31
|
end
|
32
32
|
|
33
|
+
def can_skip_confirmation?
|
34
|
+
try(:is_admin?) || email.blank?
|
35
|
+
end
|
36
|
+
|
33
37
|
class << self
|
34
38
|
def ibrain_find(params, available_columns)
|
35
39
|
matched_value = params[:username] || params[:email]
|
@@ -53,11 +57,14 @@ module Ibrain
|
|
53
57
|
end
|
54
58
|
|
55
59
|
def create_with_line!(params)
|
56
|
-
created!({
|
60
|
+
user = created!({
|
57
61
|
uid: params['uid'],
|
58
62
|
provider: 'line',
|
59
63
|
remote_avatar_url: params['info']['image']
|
60
64
|
})
|
65
|
+
|
66
|
+
user.skip_confirmation! unless user&.confirmed?
|
67
|
+
user
|
61
68
|
end
|
62
69
|
end
|
63
70
|
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
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
Ibrain::
|
3
|
+
Ibrain::Auth::Engine.routes.draw do
|
4
4
|
devise_for :users, controllers: {
|
5
5
|
sessions: "ibrain/auth/sessions",
|
6
6
|
registrations: "ibrain/auth/registrations",
|
7
|
-
callback: "ibrain/auth/sessions/callback"
|
8
7
|
},
|
9
8
|
path: "api/#{Ibrain::Config.api_version}/users",
|
10
9
|
defaults: { format: :json }
|
10
|
+
|
11
|
+
get "api/#{Ibrain::Config.api_version}/users/callback" => 'sessions#callback'
|
11
12
|
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.3.
|
7
|
+
VERSION = '0.3.4'
|
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.3.
|
14
|
+
'0.3.2'
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.ibrain_auth_gem_version
|
data/lib/ibrain/auth.rb
CHANGED
@@ -4,6 +4,10 @@ require 'devise'
|
|
4
4
|
require 'devise-encryptable'
|
5
5
|
require 'devise/jwt'
|
6
6
|
require 'omniauth'
|
7
|
+
require 'omniauth-facebook'
|
8
|
+
require 'omniauth-google-oauth2'
|
9
|
+
require 'omniauth-line'
|
10
|
+
require 'omniauth-apple'
|
7
11
|
require 'omniauth-twitter'
|
8
12
|
require 'ibrain_core'
|
9
13
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tai Nguyen Van
|
@@ -208,7 +208,7 @@ files:
|
|
208
208
|
- app/repositories/line_repository.rb
|
209
209
|
- config/initializers/devise.rb
|
210
210
|
- config/locales/en.yml
|
211
|
-
- config/locales/
|
211
|
+
- config/locales/ja.yml
|
212
212
|
- config/locales/vi.yml
|
213
213
|
- config/routes.rb
|
214
214
|
- lib/generators/ibrain/auth/install/install_generator.rb
|