Class: Chaltron::UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Chaltron::UsersController
- Defined in:
- app/controllers/chaltron/users_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #disable ⇒ Object
- #edit ⇒ Object
- #enable ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #self_edit ⇒ Object
- #self_show ⇒ Object
- #self_update ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'app/controllers/chaltron/users_controller.rb', line 32 def create if @user.save flash[:notice] = I18n.t('chaltron.users.created') info I18n.t('chaltron.logs.users.created', current: current_user.display_name, user: @user.display_name) end respond_with(@user) end |
#destroy ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'app/controllers/chaltron/users_controller.rb', line 72 def destroy if current_user == @user redirect_to({ action: :index }, alert: I18n.t('chaltron.users.cannot_self_destroy')) else info I18n.t('chaltron.logs.users.destroyed', current: current_user.display_name, user: @user.display_name) @user.destroy respond_with(@user) end end |
#disable ⇒ Object
51 52 53 54 |
# File 'app/controllers/chaltron/users_controller.rb', line 51 def disable @user.disable! redirect_to(@user) end |
#edit ⇒ Object
23 24 |
# File 'app/controllers/chaltron/users_controller.rb', line 23 def edit end |
#enable ⇒ Object
46 47 48 49 |
# File 'app/controllers/chaltron/users_controller.rb', line 46 def enable @user.enable! redirect_to(@user) end |
#index ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'app/controllers/chaltron/users_controller.rb', line 8 def index @filters = filter_params # apply provider filter @users = @users.where(provider: nil) if @filters[:provider] == 'local' @users = @users.where(provider: :ldap) if @filters[:provider] == 'ldap' # apply activity filter @users = @users.where(sign_in_count: 0) if @filters[:activity] == 'no_login' end |
#new ⇒ Object
20 21 |
# File 'app/controllers/chaltron/users_controller.rb', line 20 def new end |
#self_edit ⇒ Object
29 30 |
# File 'app/controllers/chaltron/users_controller.rb', line 29 def self_edit end |
#self_show ⇒ Object
26 27 |
# File 'app/controllers/chaltron/users_controller.rb', line 26 def self_show end |
#self_update ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/chaltron/users_controller.rb', line 56 def self_update user_params_with_pass = self_update_params.dup.to_h if params[:user][:password].present? user_params_with_pass.merge!( password: params[:user][:password], password_confirmation: params[:user][:password_confirmation], ) end if current_user.update(user_params_with_pass) flash[:notice] = I18n.t('chaltron.users.self_updated') render :self_show else render :self_edit end end |
#show ⇒ Object
17 18 |
# File 'app/controllers/chaltron/users_controller.rb', line 17 def show end |
#update ⇒ Object
41 42 43 44 |
# File 'app/controllers/chaltron/users_controller.rb', line 41 def update flash[:notice] = I18n.t('chaltron.users.updated') if @user.update(update_params) respond_with(@user) end |