Sha256: e2515167c5553904556163b427b105e4e1da84ddc3023d5ff442990898917ff6
Contents?: true
Size: 1.46 KB
Versions: 3
Compression:
Stored size: 1.46 KB
Contents
class Spree::UsersController < Spree::StoreController before_action :set_current_order, except: :show prepend_before_action :authorize_actions, only: :new include Spree::Core::ControllerHelpers def show load_object @orders = @user.orders.for_store(current_store).complete.order('completed_at desc') end def edit load_object end def create @user = Spree.user_class.new(user_params) if @user.save if current_order session[:guest_token] = nil end redirect_back_or_default(root_url) else render :new end end def update load_object if @user.update(user_params) if params[:user][:password].present? # this logic needed b/c devise wants to log us out after password changes Spree.user_class.reset_password_by_token(params[:user]) if Spree::Auth::Config[:signout_after_password_change] sign_in(@user, event: :authentication) else bypass_sign_in(@user) end end redirect_to spree.account_path, notice: Spree.t(:account_updated) else render :edit end end private def user_params params.require(:user).permit(Spree::PermittedAttributes.user_attributes) end def load_object @user ||= spree_current_user authorize! params[:action].to_sym, @user end def authorize_actions authorize! params[:action].to_sym, Spree.user_class.new end def accurate_title Spree.t(:my_account) end end
Version data entries
3 entries across 3 versions & 1 rubygems