lol_auth 0.1.12 → 0.1.13

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: 352a007dc98b7d65e1ee01ac6644b7db8e6941e78260cbc5248e6722db3c7fb1
4
- data.tar.gz: b61a73538a23be860870fb30ebc7995bfc41cc56b249cc51d098a480bb3af8c7
3
+ metadata.gz: fe4b29b9a735ff6a60a6c87d6ec15621334fa243c95c7e80b92b7723e106ba05
4
+ data.tar.gz: b6b440b72708c5e9cadcd4b26ec6ae74b14ea517b11b0afbf637215c58fab4ca
5
5
  SHA512:
6
- metadata.gz: 3bf53fb2d6b62b4175c52b5ac6a381f5ea3e3af0f320b8f7287fc0c939099c5352dde3f32d59abcea1524725b0210d7bbd85f364d42736e1410ec9a8413d786e
7
- data.tar.gz: c8a97df9c2779e08acb174d9957c943e5b4a33564d68091364f7514be2d7f4db9ec6ebd287c7f5808cdce453b44b9824fff3c1d1edaa6305355763c9c8a8720a
6
+ metadata.gz: 4d61cb6aa55774466a8af89e30de20921668c43d8ae9effd36cb515085a0f25fa6543c8e82a5ed6dc4f57b033400c4dbba82eb858946f19fe16bcf2d21f103ec
7
+ data.tar.gz: 9bd975e38537be5fa84312cb7fcbaa63917bddae6a248a02c17813de6ed717d1e7c759640919d60c613c243318804c3d6839bf432e2ad145e24e563b44f91afd
@@ -9,11 +9,15 @@ module LolAuth
9
9
 
10
10
  @user = @manager.login_with_token(params[:token])
11
11
 
12
- sign_in(:user, @user, store: false, bypass: true)
12
+ if @user
13
+ sign_in(:user, @user, store: false, bypass: true)
13
14
 
14
- response.headers.merge!(@manager.auth_header)
15
+ response.headers.merge!(@manager.auth_header)
15
16
 
16
- render :success, status: 201
17
+ render :success, status: 201
18
+ else
19
+ render :error, status: 422
20
+ end
17
21
  end
18
22
 
19
23
  def apple_signin
@@ -21,11 +25,15 @@ module LolAuth
21
25
 
22
26
  @user = @manager.process()
23
27
 
24
- sign_in(:user, @user, store: false, bypass: true)
28
+ if @user
29
+ sign_in(:user, @user, store: false, bypass: true)
25
30
 
26
- response.headers.merge!(@manager.auth_header)
31
+ response.headers.merge!(@manager.auth_header)
27
32
 
28
- render :success, status: 201
33
+ render :success, status: 201
34
+ else
35
+ render :error, status: 422
36
+ end
29
37
  end
30
38
 
31
39
  def google_signin
@@ -33,11 +41,15 @@ module LolAuth
33
41
 
34
42
  @user = @manager.process()
35
43
 
36
- sign_in(:user, @user, store: false, bypass: true)
44
+ if @user
45
+ sign_in(:user, @user, store: false, bypass: true)
37
46
 
38
- response.headers.merge!(@manager.auth_header)
47
+ response.headers.merge!(@manager.auth_header)
39
48
 
40
- render :success, status: 201
49
+ render :success, status: 201
50
+ else
51
+ render :error, status: 422
52
+ end
41
53
  end
42
54
  end
43
55
 
@@ -9,6 +9,8 @@ module Apple
9
9
  end
10
10
 
11
11
  def process
12
+ return false if @user_type.constantize.where(email: @info['email']).where.not(provider: :apple).count > 0
13
+
12
14
  user = @user_type.constantize.find_or_create_by(uid: @info['email']) do |user|
13
15
  user.email = @info['email']
14
16
  user.password = build_pasword()
@@ -9,6 +9,8 @@ module Facebook
9
9
  end
10
10
 
11
11
  def login_with_token(token)
12
+ return false if @user_type.constantize.where(email: @info['email']).where.not(provider: :facebook).count > 0
13
+
12
14
  @graph = Koala::Facebook::API.new(token)
13
15
 
14
16
  get_info()
@@ -9,6 +9,8 @@ module Google
9
9
  end
10
10
 
11
11
  def process
12
+ return false if @user_type.constantize.where(email: @info['email']).where.not(provider: :google).count > 0
13
+
12
14
  user = @user_type.constantize.find_or_create_by(uid: @info['user']['id']) do |user|
13
15
  user.email = @info['user']['email']
14
16
  user.password = build_pasword()
@@ -0,0 +1 @@
1
+ json.message 'REGISTERED_WHITH_OTHER_PROVIDER'
@@ -1,3 +1,3 @@
1
1
  module LolAuth
2
- VERSION = '0.1.12'
2
+ VERSION = '0.1.13'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lol_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Zaghi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-08 00:00:00.000000000 Z
11
+ date: 2020-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -214,6 +214,7 @@ files:
214
214
  - app/views/lol_auth/passwords/complete.html.erb
215
215
  - app/views/lol_auth/passwords/new.html.erb
216
216
  - app/views/lol_auth/users/_user.json.jbuilder
217
+ - app/views/lol_auth/users/error.json.jbuilder
217
218
  - app/views/lol_auth/users/success.json.jbuilder
218
219
  - config/initializers/devise_token_auth.rb
219
220
  - config/initializers/lol_users_config.rb