Class: UsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- UsersController
- Defined in:
- app/controllers/users_controller.rb
Overview
Copyright © 2008-2013 Michael Dvorkin and contributors.
Fat Free CRM is freely distributable under the terms of MIT license. See MIT-LICENSE file or www.opensource.org/licenses/mit-license.php
Instance Method Summary collapse
-
#avatar ⇒ Object
GET /users/1/avatar GET /users/1/avatar.js —————————————————————————-.
-
#change_password ⇒ Object
PUT /users/1/change_password PUT /users/1/change_password.js —————————————————————————-.
-
#create ⇒ Object
POST /users POST /users.js —————————————————————————-.
-
#edit ⇒ Object
GET /users/1/edit.js —————————————————————————-.
-
#new ⇒ Object
GET /users/new GET /users/new.js —————————————————————————-.
-
#opportunities_overview ⇒ Object
GET /users/opportunities_overview —————————————————————————-.
-
#password ⇒ Object
GET /users/1/password GET /users/1/password.js —————————————————————————-.
-
#redraw ⇒ Object
GET /users/1/redraw —————————————————————————-.
-
#show ⇒ Object
GET /users/1 GET /users/1.js —————————————————————————-.
-
#update ⇒ Object
PUT /users/1 PUT /users/1.js —————————————————————————-.
-
#upload_avatar ⇒ Object
PUT /users/1/upload_avatar PUT /users/1/upload_avatar.js —————————————————————————-.
Methods inherited from ApplicationController
Instance Method Details
#avatar ⇒ Object
GET /users/1/avatar GET /users/1/avatar.js
66 67 68 |
# File 'app/controllers/users_controller.rb', line 66 def avatar respond_with(@user) end |
#change_password ⇒ Object
PUT /users/1/change_password PUT /users/1/change_password.js
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'app/controllers/users_controller.rb', line 106 def change_password if @user.valid_password?(params[:current_password], true) || @user.password_hash.blank? if params[:user][:password].blank? flash[:notice] = t(:msg_password_not_changed) else @user.password = params[:user][:password] @user.password_confirmation = params[:user][:password_confirmation] @user.save flash[:notice] = t(:msg_password_changed) end else @user.errors.add(:current_password, t(:msg_invalid_password)) end respond_with(@user) end |
#create ⇒ Object
POST /users POST /users.js
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/users_controller.rb', line 34 def create if @user.save if Setting.user_signup == :needs_approval flash[:notice] = t(:msg_account_created) redirect_to login_url else flash[:notice] = t(:msg_successful_signup) redirect_back_or_default profile_url end else render :new end end |
#edit ⇒ Object
GET /users/1/edit.js
50 51 52 |
# File 'app/controllers/users_controller.rb', line 50 def edit respond_with(@user) end |
#new ⇒ Object
GET /users/new GET /users/new.js
27 28 29 |
# File 'app/controllers/users_controller.rb', line 27 def new respond_with(@user) end |
#opportunities_overview ⇒ Object
GET /users/opportunities_overview
132 133 134 135 |
# File 'app/controllers/users_controller.rb', line 132 def opportunities_overview @users_with_opportunities = User.have_assigned_opportunities.order(:first_name) @unassigned_opportunities = Opportunity.my(current_user).unassigned.pipeline.order(:stage).includes(:account, :user, :tags) end |
#password ⇒ Object
GET /users/1/password GET /users/1/password.js
99 100 101 |
# File 'app/controllers/users_controller.rb', line 99 def password respond_with(@user) end |
#redraw ⇒ Object
GET /users/1/redraw
125 126 127 128 |
# File 'app/controllers/users_controller.rb', line 125 def redraw current_user.preference[:locale] = params[:locale] render js: %(window.location.href = "#{user_path(current_user)}";) end |
#show ⇒ Object
GET /users/1 GET /users/1.js
19 20 21 22 |
# File 'app/controllers/users_controller.rb', line 19 def show @user = current_user if params[:id].nil? respond_with(@user) end |
#update ⇒ Object
PUT /users/1 PUT /users/1.js
57 58 59 60 61 |
# File 'app/controllers/users_controller.rb', line 57 def update @user.update_attributes(user_params) flash[:notice] = t(:msg_user_updated) respond_with(@user) end |
#upload_avatar ⇒ Object
PUT /users/1/upload_avatar PUT /users/1/upload_avatar.js
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/controllers/users_controller.rb', line 73 def upload_avatar if params[:gravatar] @user.avatar = nil @user.save render else if params[:avatar] avatar = Avatar.create(avatar_params) if avatar.valid? @user.avatar = avatar else @user.avatar.errors.clear @user.avatar.errors.add(:image, t(:msg_bad_image_file)) end end responds_to_parent do # Without return RSpec2 screams bloody murder about rendering twice: # within the block and after yield in responds_to_parent. render && (return if Rails.env.test?) end end end |