ibrain-auth 0.3.1 → 0.3.2
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/controllers/ibrain/auth/sessions_controller.rb +6 -8
- data/app/models/ibrain/auth/user.rb +12 -0
- data/app/repositories/firebase_repository.rb +3 -5
- data/app/repositories/line_repository.rb +18 -0
- data/lib/ibrain/auth/version.rb +2 -2
- metadata +2 -3
- data/app/repositories/apple_repository.rb +0 -10
- data/app/repositories/twitter_repository.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 206a4714c39ab84c1250cf3468ab4337548dc77691ae0a2d080e4ab6cbe5037d
|
4
|
+
data.tar.gz: 0aa8cbb121f80422c166cc8f3a6374b2f7b7c669d5b5bfc008de0aa47b5f2650
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7aecfa2c1f02b07d341b16ce230816515be57bc0f542ace841c3df0719a29824de51854f205f229903b7a4bf0e49a9e1ad940fbd5f41cc63ace4d05ba2e099f
|
7
|
+
data.tar.gz: 923f20470aab2a1291d727d7d7dea26de9f78d494e1e72f516dfdc4593fd9affcac15f8559501bb8ce92fe795a6c5e7fcd28694062da0e8e0baf425b087106c1
|
@@ -14,6 +14,12 @@ class Ibrain::Auth::SessionsController < Devise::SessionsController
|
|
14
14
|
super { |resource| @resource = resource }
|
15
15
|
end
|
16
16
|
|
17
|
+
def callback
|
18
|
+
user = line_repo.find_or_initialize!
|
19
|
+
|
20
|
+
render_json_ok(user, nil)
|
21
|
+
end
|
22
|
+
|
17
23
|
# GET /resource/sign_in
|
18
24
|
# def new
|
19
25
|
# super
|
@@ -42,14 +48,6 @@ class Ibrain::Auth::SessionsController < Devise::SessionsController
|
|
42
48
|
AuthRepository.new(resource, params)
|
43
49
|
end
|
44
50
|
|
45
|
-
def twitter_repo
|
46
|
-
TwitterRepository.new(resource, request.env['omniauth.auth'])
|
47
|
-
end
|
48
|
-
|
49
|
-
def apple_repo
|
50
|
-
AppleRepository.new(resource, request.env['omniauth.auth'])
|
51
|
-
end
|
52
|
-
|
53
51
|
def line_repo
|
54
52
|
LineRepository.new(resource, request.env['omniauth.auth'])
|
55
53
|
end
|
@@ -13,6 +13,10 @@ module Ibrain
|
|
13
13
|
:recoverable, :validatable, :timeoutable,
|
14
14
|
:jwt_authenticatable, jwt_revocation_strategy: self
|
15
15
|
|
16
|
+
scope :find_by_line, ->(uid) {
|
17
|
+
find_by(uid: uid, provider: 'line')
|
18
|
+
}
|
19
|
+
|
16
20
|
def jwt_payload
|
17
21
|
# for hasura
|
18
22
|
hasura_keys = {
|
@@ -47,6 +51,14 @@ module Ibrain
|
|
47
51
|
|
48
52
|
create!(params)
|
49
53
|
end
|
54
|
+
|
55
|
+
def create_with_line!(params)
|
56
|
+
created!({
|
57
|
+
uid: params['uid'],
|
58
|
+
provider: 'line',
|
59
|
+
remote_avatar_url: params['info']['image']
|
60
|
+
})
|
61
|
+
end
|
50
62
|
end
|
51
63
|
end
|
52
64
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class FirebaseRepository < Ibrain::BaseRepository
|
4
|
-
def initialize(record,
|
4
|
+
def initialize(record, params)
|
5
5
|
super(nil, record)
|
6
6
|
|
7
7
|
@private_key_json = File.open(Ibrain::Auth::Config.firebase_private_key_path).read
|
8
8
|
@firebase_owner_email = Ibrain::Auth::Config.firebase_owner_email
|
9
|
+
@params = params
|
9
10
|
end
|
10
11
|
|
11
12
|
def generate_custom_token!
|
@@ -26,10 +27,7 @@ class FirebaseRepository < Ibrain::BaseRepository
|
|
26
27
|
|
27
28
|
private
|
28
29
|
|
29
|
-
attr_reader :private_key_json, :firebase_owner_email
|
30
|
-
|
31
|
-
def method_name
|
32
|
-
end
|
30
|
+
attr_reader :private_key_json, :firebase_owner_email, :params
|
33
31
|
|
34
32
|
def json_firebase
|
35
33
|
JSON.parse(private_key_json, symbolize_names: true)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class LineRepository < Ibrain::BaseRepository
|
4
|
+
def initialize(record, params)
|
5
|
+
super(nil, record)
|
6
|
+
|
7
|
+
@params = params
|
8
|
+
@collection = Ibrain.user_class
|
9
|
+
end
|
10
|
+
|
11
|
+
def find_or_initialize!
|
12
|
+
user = @collection.find_by_line(uid: params['uid'])
|
13
|
+
|
14
|
+
return user if user.present?
|
15
|
+
|
16
|
+
@collection.create_with_line!
|
17
|
+
end
|
18
|
+
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.2'
|
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.1'
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.ibrain_auth_gem_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.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tai Nguyen Van
|
@@ -203,10 +203,9 @@ files:
|
|
203
203
|
- app/graphql/ibrain/auth/types/input/sign_in_input.rb
|
204
204
|
- app/graphql/ibrain/auth/types/input/sign_up_input.rb
|
205
205
|
- app/models/ibrain/auth/user.rb
|
206
|
-
- app/repositories/apple_repository.rb
|
207
206
|
- app/repositories/auth_repository.rb
|
208
207
|
- app/repositories/firebase_repository.rb
|
209
|
-
- app/repositories/
|
208
|
+
- app/repositories/line_repository.rb
|
210
209
|
- config/initializers/devise.rb
|
211
210
|
- config/locales/en.yml
|
212
211
|
- config/locales/jp.yml
|