Sha256: e8bad2ac67139ea549a04cb4b13290bf82c0dd9f5047e7cf3065c864e71c99d9
Contents?: true
Size: 971 Bytes
Versions: 26
Compression:
Stored size: 971 Bytes
Contents
require 'jwt' module ForestLiana class ApplicationController < ActionController::Base before_filter :authenticate_user_from_jwt def serialize_model(model, options = {}) options[:is_collection] = false JSONAPI::Serializer.serialize(model, options) end 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 def authenticate_user_from_jwt if request.headers['Authorization'] JWT.decode request.headers['Authorization'].split[1], ForestLiana.jwt_signing_key else render nothing: true, status: 401 end end end end
Version data entries
26 entries across 26 versions & 1 rubygems