ibrain-auth 0.3.12 → 0.3.14

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: 9bf38a18f89f6e66bb4450e293ab3305fcc2b6e6d1b0826606bd208ea60c759a
4
- data.tar.gz: c7e77a73069af88f79d33e03e8556c63593aed2d0e7c9bad651bab4d7087ee92
3
+ metadata.gz: 5173b53bdb3dee4b0ba2d5e7f4e44d437bcd3e4aa574573d8989b54a0dee945d
4
+ data.tar.gz: c349e50c8b0319979fdd23279a051b7af238d09d44f4ce7a31f327f84146a915
5
5
  SHA512:
6
- metadata.gz: f2c0c9b8c895e10f062e460b7886cba2ca5c6f02fdfa66e772bb16e5cc45f1044dd647aff72033ff732c1801e079c2ff4ef65dfd88b88c26403c048d32e4d8f2
7
- data.tar.gz: 7ea121349f47cdc3e6bb728c1ee70db0509c72f88ba1f2ef033040f36fad660f1331e2cd47861c27c2ebe2a28f8abe7680b126e318955cb612d27d40100e2104
6
+ metadata.gz: 16bcd457e52d08d65a6332c85bcb7106484ea33d3dfbd4b9964349f0ecfefe6781ea4840b21359845cbb8064b4670a80fc1e9f445743e77969abf13f539907ee
7
+ data.tar.gz: e0cd0e369b2a39ee5661c31b4f7db8baf1c999c7ea7f168eefaa141bdcc5fce72cb3a1c9763df93bbb06ec2054ddd530779cae0bf9d306d1a4d5b510cb0dafc2
@@ -9,7 +9,7 @@ module Ibrain
9
9
  self.abstract_class = true
10
10
  self.table_name = Ibrain::Auth::Config.user_table_name
11
11
 
12
- # devise(*Ibrain::Auth::Config.devise_enabled_modules, jwt_revocation_strategy: self, omniauth_providers: Ibrain::Auth::Config.devise_omniauth_providers)
12
+ devise(*Ibrain::Auth::Config.devise_enabled_modules, jwt_revocation_strategy: self, omniauth_providers: Ibrain::Auth::Config.devise_omniauth_providers)
13
13
 
14
14
  scope :find_by_line, ->(uid) {
15
15
  find_by(uid: uid, provider: 'line')
@@ -68,6 +68,10 @@ module Ibrain
68
68
  user.skip_confirmation! unless user&.confirmed?
69
69
  user
70
70
  end
71
+
72
+ def random_password
73
+ (('A'..'Z').to_a.sample(4) + ["~", "!", "@", "#", "$", "%", "^", "&", "*", "_", "-"].sample(1) + ('0'..'9').to_a.sample(2) + ('a'..'z').to_a.sample(4)).join
74
+ end
71
75
  end
72
76
  end
73
77
  end
@@ -68,12 +68,14 @@ class AuthRepository < Ibrain::BaseRepository
68
68
  try(:gsub, '.com', '')
69
69
  raise ActionController::InvalidAuthenticityToken, I18n.t('ibrain.errors.account.not_found') if uid.blank?
70
70
 
71
+ provider = 'custom' if user_information.try(:fetch, 'customAuth', false) && provider.blank?
72
+
71
73
  collection.social_find_or_initialize({
72
74
  uid: uid,
73
75
  provider: provider,
74
76
  remote_avatar_url: user_information.try(:fetch, 'photoUrl', nil),
75
77
  email: user_information.try(:fetch, 'email', nil),
76
- password: 'Eco@123456'
78
+ password: collection.random_password
77
79
  })
78
80
  end
79
81
 
@@ -12,14 +12,15 @@ class FirebaseRepository < Ibrain::BaseRepository
12
12
  end
13
13
 
14
14
  def generate_custom_token!
15
- now = Time.now.to_i
15
+ iat = Time.now.to_i
16
+ exp = 60.minutes.from_now.to_i
16
17
 
17
18
  payload = {
18
19
  iss: firebase_owner_email,
19
20
  sub: firebase_owner_email,
20
21
  aud: Ibrain::Auth::Config.firebase_auth_url,
21
- iat: now,
22
- exp: now + 3600,
22
+ iat: iat,
23
+ exp: exp,
23
24
  uid: params[:uid],
24
25
  claims: {}
25
26
  }
@@ -9,8 +9,7 @@ class LineRepository < Ibrain::BaseRepository
9
9
  end
10
10
 
11
11
  def find_or_initialize!
12
- user = @collection.find_by_line(uid: params['uid'])
13
-
12
+ user = @collection.find_by_line(uid: params['code'])
14
13
  return user if user.present?
15
14
 
16
15
  @collection.create_with_line!
@@ -4,7 +4,7 @@ module Ibrain
4
4
  # frozen_string_literal: true
5
5
 
6
6
  module Auth
7
- VERSION = '0.3.12'
7
+ VERSION = '0.3.14'
8
8
 
9
9
  def self.ibrain_auth_version
10
10
  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.3.12
4
+ version: 0.3.14
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: 2023-01-04 00:00:00.000000000 Z
11
+ date: 2023-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise