<commit_before>require 'httparty'
require 'json'
class AccountsController < ApplicationController

  def index
    @title = "All Accounts"
    @account = Account.all
  end

  def new
    @title = "Create Account"
    @account = Account.new
  end

  def create
    p request.env['omniauth.auth']
    @account = Account.find_or_create_from_auth_hash(request.env['omniauth.auth'])
    if @account.broadcast_code == nil
      @account.broadcast_code = generate_code(15)
    end
    if @account.save
      if @account.persisted?
        notice = 'User was logged in.'
      else
        notice = 'User was created.'
      end
      session[:user] = @account.id
      session[:logged_in_at] = Time.now
      redirect_to account_path(@account), :flash => { :success => notice }
    else
      redirect_to new_account_url, :flash => { :errors => @account.errors }
    end
  end

  def show
    @title = "Account"
    @account = Account.find(current_user)

    if @account.is_broadcasted == false
      @response = 'Valid broadcast not found on the blockchain.'
    else
      @response = 'Valid broadcast found and confirmed.'
    end

    @providers = []
    @account.connections.each do |c|
      @providers << Provider.find(c.provider_id)
    end
  end

  def update
    @account = Account.find(params[:id])
    @account.public_key = params[:public_key]
    @account.save
    redirect_to account_path(@account), :flash => { :success => 'Account updated.' }
  end

  def logout
    token = params[:logout_token]<commit_msg>Fixed method error.<commit_after>require 'httparty'
require 'json'
class AccountsController < ApplicationController

  def index
    @title = "All Accounts"
    @account = Account.all
  end

  def new
    @title = "Create Account"
    @account = Account.new
  end

  def create
    p request.env['omniauth.auth']
    @account = Account.find_or_create_from_auth_hash(request.env['omniauth.auth'])
    if @account.broadcast_code == nil
      @account.broadcast_code = generate_code(15)
    end
    if @account.save
      if @account.persisted?
        notice = 'User was logged in.'
      else
        notice = 'User was created.'
      end
      session[:user] = @account.id
      session[:logged_in_at] = Time.now
      redirect_to account_path(@account), :flash => { :success => notice }
    else
      redirect_to new_account_url, :flash => { :errors => @account.errors }
    end
  end

  def show
    @title = "Account"
    @account = Account.find(current_user)

    if @account.is_broadcasted == false
      @response = 'Valid broadcast not found on the blockchain.'
    else
      @response = 'Valid broadcast found and confirmed.'
    end

    @providers = []
    @account.connections.each do |c|
      @providers << Provider.find(c.provider_id)
    end
  end

  def edit
    @account = Account.find(params[:id])
  end

  def update
    @account = Account.find(params[:id])
    @account.public_key = params[:public_key]
    @account.save
    redirect_to account_path(@account), :flash => { :success => 'Account updated.' }
  end

  def logout
    token = params[:logout_token]
{'fraction_non_alphanumeric': 0.11197160374314295, 'fraction_numerical': 0.0012907389480477573, 'mean_word_length': 2.8944723618090453, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '234623', 'n_tokens_mistral': 971, 'n_tokens_neox': 941, 'n_words': 242}