mmsc_app/app/controllers/public/p_customers_controller.rb
Nicolas Bally a6aa1f6074 Initial
2020-05-25 11:40:11 +02:00

46 lines
1.0 KiB
Ruby

class Public::PCustomersController < ApplicationController
layout "public"
def new
@p_customer = PCustomer.new()
@p_customer.particulars << Particular.new(:pro => false, :skip_validation => true)
@p_customer.valid_public = true
end
def create
@p_customer = PCustomer.new(params.require(:p_customer).permit!)
#@p_customer.particulars << Particular.new(:pro => true, :skip_validation => true)
@p_customer.valid_public = true
@p_customer.require_cgv = true
if @p_customer.save
@p_customer.last_sign_in_at = Time.now
@p_customer.save(:validate => false)
cookies[:p_customer_auth_token] = @p_customer.auth_token
mail_hist = MailHist.generate_mail(:fr, MailType.find_or_create("new_account"), @p_customer.email, {:arguments => {:email => @p_customer.email}, :p_customer => @p_customer, :element => @p_customer})
redirect_to public_my_account_path
else
render template: "public/p_customers/new"
end
end
end