<commit_before>class Facebooked::ConnectRenderer < ParagraphRenderer

  features '/facebooked/connect_feature'

  paragraph :login
  paragraph :visitors
  paragraph :user
  paragraph :fan_box
  paragraph :comments
  paragraph :live_stream
  paragraph :share_button
  paragraph :stream_publish
  paragraph :request_form

  def login
    @options = paragraph_options(:login)

    if editor?
      render_paragraph :feature => :facebooked_connect_login
      return
    end

    @logged_in = self.facebook_client.validate_fb_cookies(cookies)
    if @logged_in
      @fb_user = FacebookedUser.push_facebook_user self.facebook_client, myself

      if @fb_user
        if myself.id != @fb_user.end_user_id
          paragraph_action(@fb_user.end_user.action('/facebook/connect/login'))
          process_login @fb_user.end_user

          if @options.access_token_id && ! myself.has_token?(@options.access_token_id)
            redirect_paragraph :site_node => @options.edit_account_page_id
          elsif @options.forward_login == 'yes' && session[:lock_lockout]
            lock_logout = session[:lock_lockout]
            session[:lock_lockout] = nil
            redirect_paragraph lock_logout
          elsif @options.destination_page_id
            redirect_paragraph :site_node => @options.destination_page_id
          else
            redirect_paragraph :page
          end

          return
        elsif @options.access_token_id && session[:fb_access_token] != @options.access_token_id
          if ! myself.has_token?(@options.access_token_id)
            if self.site_node.id != @options.edit_account_page_id
              redirect_paragraph :site_node => @options.edit_account_page_id
              return
            end
          else
            session[:fb_access_token] = @options.access_token_id
          end
        end
      end

    elsif params[:cms_logout]
      paragraph_action(myself.action('/facebook/connect/logout')) if myself.id
      process_logout
      redirect_paragraph :page
      return
    end

    render_paragraph :feature => :facebooked_connect_login<commit_msg>Keep track if the user logged in with facebook in the session.  If user is not longer logged into facebook but logged into our site log them out of our site.<commit_after>class Facebooked::ConnectRenderer < ParagraphRenderer

  features '/facebooked/connect_feature'

  paragraph :login
  paragraph :visitors
  paragraph :user
  paragraph :fan_box
  paragraph :comments
  paragraph :live_stream
  paragraph :share_button
  paragraph :stream_publish
  paragraph :request_form

  def login
    @options = paragraph_options(:login)

    if editor?
      render_paragraph :feature => :facebooked_connect_login
      return
    end

    @logged_in = self.facebook_client.validate_fb_cookies(cookies)
    if @logged_in
      @fb_user = FacebookedUser.push_facebook_user self.facebook_client, myself

      if @fb_user
        if myself.id != @fb_user.end_user_id
          paragraph_action(@fb_user.end_user.action('/facebook/connect/login'))
          process_login @fb_user.end_user
          session[:facebook_logged_in] = true

          if @options.access_token_id && ! myself.has_token?(@options.access_token_id)
            redirect_paragraph :site_node => @options.edit_account_page_id
          elsif @options.forward_login == 'yes' && session[:lock_lockout]
            lock_logout = session[:lock_lockout]
            session[:lock_lockout] = nil
            redirect_paragraph lock_logout
          elsif @options.destination_page_id
            redirect_paragraph :site_node => @options.destination_page_id
          else
            redirect_paragraph :page
          end

          return
        elsif @options.access_token_id && session[:fb_access_token] != @options.access_token_id
          if ! myself.has_token?(@options.access_token_id)
            if self.site_node.id != @options.edit_account_page_id
              redirect_paragraph :site_node => @options.edit_account_page_id
              return
            end
          else
            session[:fb_access_token] = @options.access_token_id
          end
        end
      end
    elsif params[:cms_logout] || (myself.id && session[:facebook_logged_in])
      paragraph_action(myself.action('/facebook/connect/logout')) if myself.id
      process_logout
      redirect_paragraph :page
      return
    end

    render_paragraph :feature => :facebooked_connect_login
{'fraction_non_alphanumeric': 0.07480847228481298, 'fraction_numerical': 0.0, 'mean_word_length': 2.843290043290043, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '405607', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1229, 'n_words': 251}