Sha256: 4a3ee222d295d1671a05f0698b46c51d0f938e618b46379bb8f71b26bf9e90cd

Contents?: true

Size: 1.8 KB

Versions: 14

Compression:

Stored size: 1.8 KB

Contents

class Admin::UsersController < Admin::BaseController

  crudify :user, :order => 'login', :title_attribute => 'login'

  # Protect these actions behind an admin login
  before_filter :find_user, :except => [:new, :create]
  before_filter :load_available_plugins, :only => [:new, :create, :edit, :update]

  filter_parameter_logging 'password', 'password_confirmation'

  layout 'admin'

  def new
    @user = User.new
    @selected_plugin_titles = []
  end

  def create
    @user = User.new(params[:user])
    @selected_plugin_titles = params[:user][:plugins] || []

    if @user.save
      @user.plugins = @selected_plugin_titles
      flash[:notice] = "'#{@user.login}' was successfully created."
      redirect_to :action => 'index'
    else
      render :action => 'new'
    end
  end

  def edit
    @user = User.find params[:id]
    @selected_plugin_titles = @user.plugins.collect{|p| p.title}
  end

  def update
    @selected_plugin_titles = params[:user][:plugins]
    # Prevent the current user from locking themselves out of the User manager
    if current_user.id == @user.id and !params[:user][:plugins].include?("Users")
      flash.now[:error] = "You cannot remove the 'Users' plugin from the currently logged in account."
      render :action => "edit"
    else
      @previously_selected_plugins_titles = @user.plugins.collect{|p| p.title}
      if @user.update_attributes params[:user]
        flash[:notice] = "'#{@user.login}' was successfully updated."
        redirect_to admin_users_url
      else
        @user.plugins = @previously_selected_plugins_titles
        @user.save
        render :action => 'edit'
      end
    end
  end

protected

  def can_create_public_user
    User.count == 0
  end

  def load_available_plugins
    @available_plugins = Refinery::Plugins.registered.in_menu.titles.sort
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
refinerycms-0.9.6.34 vendor/plugins/authentication/app/controllers/admin/users_controller.rb
refinerycms-0.9.6.33 vendor/plugins/authentication/app/controllers/admin/users_controller.rb
refinerycms-0.9.6.32 vendor/plugins/authentication/app/controllers/admin/users_controller.rb
refinerycms-0.9.6.31 vendor/plugins/authentication/app/controllers/admin/users_controller.rb
refinerycms-0.9.6.30 vendor/plugins/authentication/app/controllers/admin/users_controller.rb
refinerycms-0.9.6.29 vendor/plugins/authentication/app/controllers/admin/users_controller.rb
refinerycms-0.9.6.28 vendor/plugins/authentication/app/controllers/admin/users_controller.rb
refinerycms-0.9.6.27 vendor/plugins/authentication/app/controllers/admin/users_controller.rb
refinerycms-0.9.6.26 vendor/plugins/authentication/app/controllers/admin/users_controller.rb
refinerycms-0.9.6.25 vendor/plugins/authentication/app/controllers/admin/users_controller.rb
refinerycms-0.9.6.24 vendor/plugins/authentication/app/controllers/admin/users_controller.rb
refinerycms-0.9.6.23 vendor/plugins/authentication/app/controllers/admin/users_controller.rb
refinerycms-0.9.6.22 vendor/plugins/authentication/app/controllers/admin/users_controller.rb
refinerycms-0.9.6.21 vendor/plugins/authentication/app/controllers/admin/users_controller.rb