class Prime::SessionsController < Prime::ApplicationController
  layout 'prime_sessions'

  skip_before_action :require_prime_user
  skip_before_action :require_mfa

  def new
    referrer = URI(request.referer) rescue nil

    application_host = ENV.fetch('APPLICATION_HOST', Rails.application.secrets.application_host)
    application_protocol = ENV.fetch('APPLICATION_PROTOCOL', Rails.application.secrets.application_protocol)

    if referrer && application_host
      referrer.host, referrer.port = application_host
      referrer.port = nil if referrer.port == 80
      referrer.scheme = application_protocol
      @return_path = referrer.to_s
    end
  end
end
