52 lines
1.3 KiB
Ruby
52 lines
1.3 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
|
|
|
|
@p_customer.enabled = false
|
|
|
|
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.auto_generate_mail(:fr, "confirmer-inscription", @p_customer.email, {:arguments => {:lien => valid_account_public_p_customer_auths_url(:token => @p_customer.mlm_token) }, :p_customer => @p_customer})
|
|
|
|
#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
|