class Traces::TraceUsersController < Traces::BaseController

  def create  
    if current_user.trace_token.present?
      set_trace_token_to_cookie
      render :json => {view_domain: "#{Trace.trace_config[:view_domain]}/ai/dashboard"}
    else
      render_error(-1,  "代码溯源用户初始化失败")
    end
  rescue Exception => exception
    puts exception.message
    normal_status(-1, exception.message)
  end

  private 
  
  def set_trace_token_to_cookie
    cookies[:vue_admin_template_token] = {
      :value => current_user&.trace_token,
      :expires => 1.hours.from_now,
      :domain => Trace.trace_config[:cookie_domain]
    }
  end

end