ibrain-auth 0.3.13 → 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: 8c4349772e38156afa066d4fda39aba790be46230aea760585ac2857fdbd1562
4
- data.tar.gz: a564f50845cdd14359f57a3ee0c1fde568adea39109c0330c60a5a5904b74723
3
+ metadata.gz: 5173b53bdb3dee4b0ba2d5e7f4e44d437bcd3e4aa574573d8989b54a0dee945d
4
+ data.tar.gz: c349e50c8b0319979fdd23279a051b7af238d09d44f4ce7a31f327f84146a915
5
5
  SHA512:
6
- metadata.gz: 248e52d90169fb7905e805556065cadab6c69ddfd6aa79edc0c90b0fb8261e25c1ad5ec2e4793af4b87f1c7978293f8d05cc626514ab6b2fb315ccd7d67e5250
7
- data.tar.gz: 0ca26294856bdac8bb949880dfcc06ce9e66c0ca809e720e3b3b72cd9b40c2e1a222867ebd077e3c9ac44bb3265e9155956e585adbbe98e50f314a97ff8fcc88
6
+ metadata.gz: 16bcd457e52d08d65a6332c85bcb7106484ea33d3dfbd4b9964349f0ecfefe6781ea4840b21359845cbb8064b4670a80fc1e9f445743e77969abf13f539907ee
7
+ data.tar.gz: e0cd0e369b2a39ee5661c31b4f7db8baf1c999c7ea7f168eefaa141bdcc5fce72cb3a1c9763df93bbb06ec2054ddd530779cae0bf9d306d1a4d5b510cb0dafc2
@@ -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.13'
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.13
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