File tree Expand file tree Collapse file tree 5 files changed +24
-6
lines changed
api_authentication/facebook
concerns/api_authentication Expand file tree Collapse file tree 5 files changed +24
-6
lines changed Original file line number Diff line number Diff line change 1
1
class ApiAuthentication ::Facebook ::SessionsController < ApiAuthentication ::BaseController
2
2
skip_before_action :authenticate! , only : :create
3
3
4
+ attr_reader :resource
5
+
4
6
private
5
- def build_resource
6
- @session = ::ApiAuthentication ::Session . social_login . facebook . new resource_params
7
- end
8
7
9
- def resource
10
- @session
8
+ def build_resource
9
+ @resource = :: ApiAuthentication :: Session . social_login . facebook . new resource_params
11
10
end
12
11
13
12
def resource_params
Original file line number Diff line number Diff line change @@ -72,6 +72,16 @@ def decode_jwt_hash_by token
72
72
73
73
@current_user_id = current_jwt_hash [ :user ] [ :id ]
74
74
75
+ #
76
+ # is_blocked
77
+ #
78
+ if \
79
+ ApiAuthentication . configuration . handle_users_is_blocked &&
80
+ current_user_with_only_is_blocked . respond_to? ( :is_blocked ) &&
81
+ current_user_with_only_is_blocked . is_blocked?
82
+ return false
83
+ end
84
+
75
85
return true
76
86
rescue JWT ::DecodeError
77
87
return false
@@ -83,6 +93,11 @@ def current_user
83
93
"::#{ ApiAuthentication . configuration . app_user_model_class_name . constantize } " . constantize . find current_user_id
84
94
end
85
95
96
+ def current_user_with_only_is_blocked
97
+ @current_user ||=
98
+ "::#{ ApiAuthentication . configuration . app_user_model_class_name . constantize } " . constantize . select ( :is_blocked ) . find current_user_id
99
+ end
100
+
86
101
def current_session
87
102
@current_session ||= ::ApiAuthentication ::Session . find_by_token! current_token
88
103
end
Original file line number Diff line number Diff line change @@ -42,5 +42,7 @@ class Configuration
42
42
43
43
config_accessor ( :app_user_model_class_name ) { 'User' }
44
44
45
+ config_accessor ( :handle_users_is_blocked ) { false }
46
+
45
47
end
46
48
end
Original file line number Diff line number Diff line change 1
1
module ApiAuthentication
2
- VERSION = '0.2.0 '
2
+ VERSION = '0.2.1 '
3
3
end
Original file line number Diff line number Diff line change 34
34
# => allow to set up in-app class name of user model
35
35
#
36
36
# config.app_user_model_class_name = 'User'
37
+
38
+ # config.handle_users_is_blocked = false
37
39
end
You can’t perform that action at this time.
0 commit comments