class Api::V1::BaseController
Attributes
current_user[RW]
current_user_token[RW]
Protected Instance Methods
requires_authentication_token()
click to toggle source
# File lib/generators/happy_seed/api/templates/app/controllers/api/v1/base_controller.rb, line 12 def requires_authentication_token authenticate_or_request_with_http_token do |token, _| self.current_user_token = UserToken.find_by access_token: token self.current_user = sign_in(:user, current_user_token.user) if current_user_token.try(:user).present? current_user.present? ? (current_user_token.try(:touch); true) : false end end
set_user()
click to toggle source
# File lib/generators/happy_seed/api/templates/app/controllers/api/v1/base_controller.rb, line 8 def set_user @user = params[:user_id].present? ? User.where(id: params[:user_id]).first : nil end