Class: ForestLiana::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- ForestLiana::ApplicationController
show all
- Defined in:
- app/controllers/forest_liana/application_controller.rb
Instance Method Summary
collapse
Instance Method Details
#authenticate_user_from_jwt ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'app/controllers/forest_liana/application_controller.rb', line 33
def authenticate_user_from_jwt
if request.['Authorization']
@jwt_decoded_token = JWT.decode(
request.['Authorization'].split[1],
ForestLiana.jwt_signing_key).try(:first)
else
render nothing: true, status: 401
end
end
|
#current_user ⇒ Object
7
8
9
|
# File 'app/controllers/forest_liana/application_controller.rb', line 7
def current_user
@jwt_decoded_token
end
|
#serialize_model(model, options = {}) ⇒ Object
11
12
13
14
|
# File 'app/controllers/forest_liana/application_controller.rb', line 11
def serialize_model(model, options = {})
options[:is_collection] = false
JSONAPI::Serializer.serialize(model, options)
end
|
#serialize_models(models, options = {}) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/forest_liana/application_controller.rb', line 16
def serialize_models(models, options = {})
options[:is_collection] = true
json = JSONAPI::Serializer.serialize(models, options)
if options[:count]
json[:meta] = {} unless json[:meta]
json[:meta][:count] = options[:count]
end
if !options[:has_more].nil?
json[:meta] = {} unless json[:meta]
json[:meta][:has_more] = options[:has_more]
end
json
end
|