class Public::ProductCustomersController < ApplicationController layout "public" before_filter :auth_product_customer, :except => [:new, :create, :confirm] def index @product_customers = ProductCustomer.all end def new if params[:r] and params[:r] != "" session[:before_auth_url] = nil end @no_search = true if params[:for_annonce] and params[:for_annonce] != "" session[:for_annonce] = true params[:step] = "login" else session[:for_annonce] = nil params[:for_annonce] = nil end params[:for_mail] =nil if params[:for_mail] == "" @product_customer = ProductCustomer.new() end def edit @product_customer = ProductCustomer.find(params[:id]) end def create @product_customer = ProductCustomer.new(params.require(:product_customer).permit!) @product_customer.remote_ip = request.remote_ip if @product_customer.save #ProductCustomerMailer.confirm(@product_customer).deliver @product_customer.authenticate(params[:password]) cookies[:product_customer_auth_token] = @product_customer.token redirect_to particulars_public_product_orders_path else render :template => "public/product_customers_auths/new" end end def confirm @product_customer = ProductCustomer.find_by_token(params[:id]) @product_customer.enabled = true @product_customer.save(:validate => false) cookies[:product_customer_auth_token] = @product_customer.token redirect_to public_my_account_path #redirect_to "/" end def update @product_customer = ProductCustomer.find(params[:id]) if params[:order] @product_customer.force_address = true end if @product_customer == current_product_customer if @product_customer.update_attributes(params.require(:product_customer).permit!) if params[:order] @product_customer = current_product_customer @order.product_customer = @product_customer render :template => "public/orders/new" else redirect_to public_my_account_path end else if params[:order] @order = Order.new(session[:order]) render :template => "public/orders/billing" else render :template => "public/my_account/edit_infos" end end end end end