Module: Mokio::Concerns::Controllers::Users
- Extended by:
- ActiveSupport::Concern
- Includes:
- Mokio::Concerns::Common::Translations
- Included in:
- UsersController
- Defined in:
- lib/mokio/concerns/controllers/users.rb
Overview
Concern for UsersController
Instance Method Summary collapse
-
#edit_password ⇒ Object
Editing password for user.
-
#new ⇒ Object
Overwritten new from CommonController#new (Mokio::Concerns::Controllers::Common).
- #set_breadcrumbs_prefix ⇒ Object
-
#update ⇒ Object
Overwritten new from CommonController#update (Mokio::Concerns::Controllers::Common).
-
#update_password ⇒ Object
Updating password for user.
Instance Method Details
#edit_password ⇒ Object
Editing password for user
52 53 54 55 56 57 |
# File 'lib/mokio/concerns/controllers/users.rb', line 52 def edit_password set_obj # Request Referer for redirect user in the place where it was before the change password session[:return_to] = request.referer @password_only = true end |
#new ⇒ Object
Overwritten new from CommonController#new (Mokio::Concerns::Controllers::Common)
18 19 20 |
# File 'lib/mokio/concerns/controllers/users.rb', line 18 def new @user = Mokio::User.new end |
#set_breadcrumbs_prefix ⇒ Object
79 80 81 82 |
# File 'lib/mokio/concerns/controllers/users.rb', line 79 def @breadcrumbs_prefix = "settings" @breadcrumbs_prefix_link = "" end |
#update ⇒ Object
Overwritten new from CommonController#update (Mokio::Concerns::Controllers::Common)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mokio/concerns/controllers/users.rb', line 25 def update # raise current_user.inspect @current = current_user respond_to do |format| if obj.update(obj_params) if obj.id == @current.id #only when password os changed for current user, sign in (with updated password) is required sign_in(obj, :bypass => true) end if !params[:save_and_new].blank? format.html { redirect_to obj_new_url(@obj_class.new), notice: CommonTranslation.updated(obj) } format.json { head :no_content } else format.html { redirect_to obj_index_url, notice: CommonTranslation.updated(obj) } format.json { render action: 'index', status: :created, location: obj } end else format.html { render "edit", notice: CommonTranslation.not_updated(obj) } format.json { render json: @obj.errors, status: :unprocessable_entity } end end end |
#update_password ⇒ Object
Updating password for user
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/mokio/concerns/controllers/users.rb', line 62 def update_password set_obj @user.only_password = true respond_to do |format| if @user.update(user_params) sign_in(@user, :bypass => true) format.html { redirect_to session[:return_to] ,notice: I18n.t("users.password_updated") } # format.json { render action: 'edit_password', status: :updated} else @password_only = true format.html { render "edit_password", notice: I18n.t("users.password_not_updated") } format.json { render json: @user.errors, status: :unprocessable_entity } end end end |