Class: Muck::UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Muck::UsersController
- Defined in:
- app/controllers/muck/users_controller.rb
Instance Method Summary collapse
- #activation_instructions ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #is_email_available ⇒ Object
- #is_login_available ⇒ Object
- #login_search ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #welcome ⇒ Object
Instance Method Details
#activation_instructions ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/controllers/muck/users_controller.rb', line 27 def activation_instructions @page_title = t('muck.users.welcome') @user = User.find(params[:id]) respond_to do |format| format.html { render :template => 'users/activation_instructions' } end end |
#create ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/muck/users_controller.rb', line 47 def create @page_title = t('muck.users.register_account', :application_name => MuckEngine.configuration.application_name) .delete :auth_token @user = User.new(params[:user]) setup_tos check_access_code check_recaptcha success, path = setup_user after_create_response(success, path) end |
#destroy ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'app/controllers/muck/users_controller.rb', line 69 def destroy return unless admin? || MuckUsers.configuration.let_users_delete_their_account @user = admin? ? User.find(params[:id]) : User.find(current_user) if @user.destroy flash[:notice] = t("muck.users.user_account_deleted") end after_destroy_response end |
#edit ⇒ Object
41 42 43 44 45 |
# File 'app/controllers/muck/users_controller.rb', line 41 def edit @page_title = t('muck.users.update_profile') @user = admin? ? User.find(params[:id]) : current_user standard_response('edit', true) end |
#is_email_available ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'app/controllers/muck/users_controller.rb', line 119 def is_email_available if params[:user_email].nil? result = '' elsif params[:user_email].empty? result = t('muck.users.email_empty') elsif !User.email_exists?(params[:user_email]) valid, errors = valid_email?(params[:user_email]) if valid result = t('muck.users.email_available') else result = t('muck.users.email_invalid') end else recover_password_prompt = render_to_string :partial => 'users/recover_password_via_email_link', :locals => { :email => params[:user_email] } result = t('muck.users.email_not_available', :reset_password_help => recover_password_prompt.html_safe).html_safe respond_to do |format| format.html { render :partial => 'users/unavailable', :locals => { :message => result.html_safe } } format.js { render :partial => 'users/unavailable', :locals => { :message => result } } end return end respond_to do |format| if errors.blank? && ! result.nil? format.html { render :partial => 'users/available', :locals => { :message => result } } format.js { render :partial => 'users/available', :locals => { :message => result } } else format.html { render :partial => 'users/unavailable', :locals => { :message => result } } format.js { render :partial => 'users/unavailable', :locals => { :message => result } } end end end |
#is_login_available ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'app/controllers/muck/users_controller.rb', line 90 def is_login_available result = t('muck.users.username_not_available') if params[:user_login].nil? result = '' elsif params[:user_login].empty? result = t('muck.users.login_empty') elsif !User.login_exists?(params[:user_login]) @user = User.new(:login => params[:user_login]) @user.valid? # we aren't interested in the output of this. if !@user.errors[:login].blank? result = "#{t('muck.users.invalid_username')} <br /> #{t('muck.users.username')} #{@user.errors[:login]}" else result = t('muck.users.username_available') end end respond_to do |format| if !@user.blank? && @user.errors[:login].blank? && !result.blank? format.html { render :partial => 'users/available', :locals => { :message => result } } format.js { render :partial => 'users/available', :locals => { :message => result } } else format.html { render :partial => 'users/unavailable', :locals => { :message => result } } format.js { render :partial => 'users/unavailable', :locals => { :message => result } } end #format.html { render :text => result } #format.js { render :text => result } end end |
#login_search ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/muck/users_controller.rb', line 78 def login_search if params[:q] @users = User.by_login_alpha.by_login(params[:q], :limit => params[:limit] || 100) else @users = User.by_login_alpha(:limit => params[:limit] || 100) end respond_to do |format| format.js { render :text => @users.collect{|user| user.login }.join("\n") } format.json { render :json => @users.collect{|user| { :login => user.login } }.to_json } end end |
#new ⇒ Object
35 36 37 38 39 |
# File 'app/controllers/muck/users_controller.rb', line 35 def new @page_title = t('muck.users.register_account', :application_name => MuckEngine.configuration.application_name) @user = User.new standard_response('new', true) end |
#show ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/muck/users_controller.rb', line 8 def show @user = User.find(params[:id]) if params[:id] @user ||= current_user if @user == current_user @page_title = @user.to_param standard_response('show', true) else standard_response('show', false, public_user_path(@user)) end end |
#update ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/muck/users_controller.rb', line 58 def update @title = t("users.update_profile") @user = admin? ? User.find(params[:id]) : User.find(current_user) if @user.update_attributes(params[:user]) flash[:notice] = t("muck.users.user_update") after_update_response(true) else after_update_response(false) end end |
#welcome ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/controllers/muck/users_controller.rb', line 19 def welcome @page_title = t('muck.users.welcome') @user = User.find(params[:id]) respond_to do |format| format.html { render :template => 'users/welcome' } end end |