Sha256: f9453b07553be62071d45aad1b7d30339e15b89eb97f29e544cf077b586494a0

Contents?: true

Size: 1.83 KB

Versions: 14

Compression:

Stored size: 1.83 KB

Contents

class MyAccountsController < ApplicationController
  before_filter :authenticate_user!

  def show
    @user = current_user

    respond_to do |format|
      format.html
      format.json { render :json => @user }
    end
  end

  def edit
    @user = current_user
    if defined?(EnjuCirculation)
      if params[:mode] == 'feed_token'
        if params[:disable] == 'true'
          @user.delete_checkout_icalendar_token
        else
          @user.reset_checkout_icalendar_token
        end
        render :partial => 'feed_token'
        return
      end
    end
    prepare_options
  end

  def update
    @user = current_user

    respond_to do |format|
      if current_user.has_role?('Librarian')
        saved = current_user.update_with_password(params[:user], :as => :admin)
      else
        saved = current_user.update_with_password(params[:user])
      end

      if saved
        sign_in(current_user, :bypass => true)
        format.html { redirect_to my_account_url, :notice => t('controller.successfully_updated', :model => t('activerecord.models.user')) }
        format.json { head :no_content }
      else
        @user = current_user
        prepare_options
        format.html { render :action => "edit" }
        format.json { render :json => current_user.errors, :status => :unprocessable_entity }
      end
    end
  end

  def destroy
    @user = current_user
    @user.destroy

    respond_to do |format|
      format.html { redirect_to my_account_url, :notice => 'devise.registrations.destroyed' }
      format.json { head :no_content }
    end
  end

  private
  def prepare_options
    @user_groups = UserGroup.all
    @roles = Role.all
    @libraries = Library.all_cache
    @languages = Language.all_cache
    if current_user.active_for_authentication?
      current_user.locked = '0'
    else
      current_user.locked = '1'
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
enju_leaf-1.1.0.rc12 app/controllers/my_accounts_controller.rb
enju_leaf-1.1.0.rc11 app/controllers/my_accounts_controller.rb
enju_leaf-1.1.0.rc10 app/controllers/my_accounts_controller.rb
enju_leaf-1.1.0.rc9 app/controllers/my_accounts_controller.rb
enju_leaf-1.1.0.rc8 app/controllers/my_accounts_controller.rb
enju_leaf-1.1.0.rc7 app/controllers/my_accounts_controller.rb
enju_leaf-1.1.0.rc6 app/controllers/my_accounts_controller.rb
enju_leaf-1.1.0.rc5 app/controllers/my_accounts_controller.rb
enju_leaf-1.1.0.rc4 app/controllers/my_accounts_controller.rb
enju_leaf-1.1.0.rc3 app/controllers/my_accounts_controller.rb
enju_leaf-1.1.0.rc2 app/controllers/my_accounts_controller.rb
enju_leaf-1.1.0.rc1 app/controllers/my_accounts_controller.rb
enju_leaf-1.1.0.beta3 app/controllers/my_accounts_controller.rb
enju_leaf-1.1.0.pre3 app/controllers/my_accounts_controller.rb