11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/softwear/auth/token_authentication.rb', line 11
def token_authenticate_user!
user_class = self.class.user_class || base_class.user_class || User
options = (self.class.token_auth_options || base_class.token_auth_options || {}).with_indifferent_access
params_options = (options[:params] || {}).with_indifferent_access
= (options[:headers] || {}).with_indifferent_access
email_param = params_options[:email] || 'user_email'
token_param = params_options[:authentication_token] || 'user_token'
= [:email] || 'X-User-Email'
= [:authentication_token] || 'X-User-Token'
email = params[email_param] || request.[]
token = params[token_param] || request.[]
return render_unauthorized if email.blank? || token.blank?
case user_class.query "token #{Figaro.env.hub_app_name} #{email} #{token}"
when 'no' then render_unauthorized
when 'invaild' then render_unauthorized
when 'sorry' then render_internal_server_error
when 'yes' then true
end
end
|