Sha256: 30d925adce5bbfea214bc6f475ae57506bfb02447a04bb8cc1b2df2375f8065f

Contents?: true

Size: 1000 Bytes

Versions: 2

Compression:

Stored size: 1000 Bytes

Contents

UserSessionsController.class_eval do

  layout "sign_in"

  # SSL is required in the Gem for new, create, update, and destroy

  def destroy
    session.clear
    super
    # added flash notice when users log out
    flash[:notice] = I18n.t("logged_out")
  end

  def create
    authenticate_user!
    if user_signed_in?
      respond_to do |format|
        format.html {
          flash[:notice] = I18n.t("logged_in_succesfully")
          if current_user.has_role?("vendor")
            redirect_to admin_vendor_overview_index_path
          elsif current_user.has_role?("admin")
            redirect_to admin_overview_index_path
          else
            redirect_back_or_default(root_path)
          end
        }
        format.js {
          user = resource.record
          render :json => {:ship_address => user.ship_address, :bill_address => user.bill_address}.to_json
        }
      end
    else
      flash[:error] = I18n.t("devise.failure.invalid")
      render :new
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_suppliers-0.0.1 app/controllers/user_sessions_decorator.rb
spree_suppliers-0.60.3 app/controllers/user_sessions_decorator.rb