Sha256: fcb5b0291ff9a88519f16ac2bdc6e404ac67f898e46f7a7bd3b1308cc485a5f3
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
class UsersController < InheritedResources::Base respond_to :html, :js, :only=>[:edit, :show, :update, :change_password] respond_to :json, :only=>[:verify_password] before_filter :authenticate_user!, :resource def edit respond_with(resource) end def update if params[:commit] == "Update Account" @user = User.find(params[:id]) @user._validators.delete_if{|k,v| k.in?(:password, :password_confirmation)} params[:user].delete_if{|k,v| k.in?("password", "password_confirmation")} @user.class_eval do attr_accessor :old_password validates :email, :presence => true, :email => true validates :old_password, :presence=>true, :password=>true end else @user = resource end update! do |success, failure| failure.html{redirect_to my_account_path} success.html{flash[:notice] = "Your account has been updated."; redirect_to root_url} end end def verify respond_with resource do |format| format.json {render :json=> resource.valid_password?(params[:password]).to_json} end end def resource @user ||= FullyValidatedUser.find(current_user) end end
Version data entries
6 entries across 6 versions & 1 rubygems