Sha256: fad333f7f783af6372e40e5c3b880604c125f962b8916da504b2e737497ceee6

Contents?: true

Size: 952 Bytes

Versions: 6

Compression:

Stored size: 952 Bytes

Contents

class GreenFlag::Admin::WhiteListUsersController < ApplicationController

  def index
    feature_id = params[:feature_id]
    users = GreenFlag::FeatureDecision.whitelisted_users(feature_id)

    users.each { |u| u.include_root_in_json = false }

    respond_to do |format|
      format.js { render :json => users.to_json }
    end
  end

  def create
    feature_id = params[:feature_id]
    feature = GreenFlag::Feature.find(feature_id)

    user = User.where(email: params[:email]).first
    GreenFlag::FeatureDecision.whitelist_user!(feature.code, user)

    user.include_root_in_json = false

    respond_to do |format|
      format.js { render :json => user.to_json }
    end
  end

  def destroy
    feature_id = params[:feature_id]
    user_id = params[:id]

    fd = GreenFlag::FeatureDecision.for_user(user_id).for_feature(feature_id).first
    fd.destroy

    respond_to do |format|
      format.js { render :json => '' }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
green_flag-0.4.0 app/controllers/green_flag/admin/white_list_users_controller.rb
green_flag-0.3.0 app/controllers/green_flag/admin/white_list_users_controller.rb
green_flag-0.2.0 app/controllers/green_flag/admin/white_list_users_controller.rb
green_flag-0.1.2 app/controllers/green_flag/admin/white_list_users_controller.rb
green_flag-0.1.1 app/controllers/green_flag/admin/white_list_users_controller.rb
green_flag-0.1.0 app/controllers/green_flag/admin/white_list_users_controller.rb