module Api::UserHelper
  extend ActiveSupport::Concern

  def load_observe_user 
    username = params[:owner]

    @observe_user = User.find_by(login: username)

    if @observe_user
      logger.info "###########observe_user not founded"
			@observe_user
    else
			logger.info "###########observe_user not found"
      @observe_user = nil
       render_not_found and return
    end
    @observe_user
  end

  # 是否具有查看用户或编辑用户的权限
  def check_auth_for_observe_user 
   return render_forbidden unless current_user.admin? || @observe_user.id == current_user.id
  end

  def strip(str)
    str.to_s.strip.presence
  end
end