ibrain-auth 0.3.3 → 0.3.4

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: 5c08fcfe12771e9c3cdde0a63bc0250d51cd5c7f27f9b082d0d835867a8d52b6
4
- data.tar.gz: a876783c23b3109877d3f4f9d8e88d004e053996ae3ea710910c37d00cda6b9b
3
+ metadata.gz: 2c770305135ae26248db7449d6aaa479a77e15c3935888096eb50eff4baf8284
4
+ data.tar.gz: d3193ce7139a9325aa51f3a4da3af93bee63ae057553a5b4dbb6eb940f2863e0
5
5
  SHA512:
6
- metadata.gz: 141d5cc986c569da43a09c1621c3b17aba77d5906eb794c8edcb837f0796b7f678cd62c35dd2d87ba701808536c717949e8e313e770ca9658d1dc8d8d39d9756
7
- data.tar.gz: 104b92ead3c2452fe1e891567712883c5832978c1dce0d931ad291b33289a579f56e9df67172d410c58a91799d0bb551d1d83032b0fbfc7842e598460fd203c6
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
@@ -10,4 +10,5 @@ en:
10
10
  expired_session: The login session has expired.
11
11
  account:
12
12
  not_found: Account not found
13
- incorrect: Username or Password is incorrect!
13
+ incorrect: Username or Password is incorrect!
14
+ not_verified: Please verify your account before login
@@ -1,4 +1,4 @@
1
- jp:
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: ログインする前にアカウントを確認してください
@@ -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
@@ -4,7 +4,7 @@ module Ibrain
4
4
  # frozen_string_literal: true
5
5
 
6
6
  module Auth
7
- VERSION = '0.3.3'
7
+ VERSION = '0.3.4'
8
8
 
9
9
  def self.ibrain_auth_version
10
10
  VERSION
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.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/jp.yml
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