class MobileAppApi::V1::BaseController < ApplicationController

  respond_to :json

  rescue_from Exception do |e|
    render json: { status: 500 , error: "Something went wrong. Please try again with valid credentials.", error_details: e.message.inspect}
  end

  # Api to check valid user login
  def login_required!
    User.current = nil
    unless params[:auth_token].blank?
      @user = User.find_by(auth_token: params[:auth_token])
      if @user
        User.current = @user
      else
        render json: { status: 400, error: "Invalid user. Login and try again." }
      end
    else
      render json: { status: 400, error: "Auth token not found in request." }
    end
  end

end
