<commit_before>class ProfileController < ApplicationController
  before_action :authenticate_user!

  helper_method :update_profile

  def index
  end

  def show
  end

  def new
  end

  def edit
  end

  def update_profile
  	@me = User.find_by(id: current_user.id)
    @me.email = params["email"]
    @me.email_notification = params["emailnotifications"]
    @me.fullname = params["fullname"]
    @me.office_location = params["officelocation"]
    @me.office_phone = params["officephone"]
    @me.mobile_phone = params["mobilephone"]
    @me.language = params["language"]

    @me.student = is_student(params["email"])

    if not is_valid_domain(params["email"])
      flash[:error] = t('devise.sessions.wrong_domain')
      redirect_to "/profile"
    elsif 
      flash[:error] = t('devise.sessions.wrong_email')
      redirect_to "/profile"
    else
      respond_to do |format|
        if @me.save
          format.html { redirect_to "/", notice: t('notices.successful_update', :model => User.model_name.human) }
          format.json { render :show }
        else
          format.html { render :new }
          format.json { render json: @me.errors, status: :unprocessable_entity }
        end
      end
    end
  end

  def is_valid_domain(email)
    domains = Rails.application.config.login["domains"]

    return (email && domains.include?(email.split('@').last))
  end

  def is_correct_account
    return (email && username == email.split('@').first)
  end

  def is_student(email)
    email_domain = email.split('@').last

    if email_domain && email_domain.split('.').first == 'student'
      return true
    else
      return false
    end
  end
end<commit_msg>Fix incorrect elsif<commit_after>class ProfileController < ApplicationController
  before_action :authenticate_user!

  helper_method :update_profile

  def index
  end

  def show
  end

  def new
  end

  def edit
  end

  def update_profile
  	@me = User.find_by(id: current_user.id)
    @me.email = params["email"]
    @me.email_notification = params["emailnotifications"]
    @me.fullname = params["fullname"]
    @me.office_location = params["officelocation"]
    @me.office_phone = params["officephone"]
    @me.mobile_phone = params["mobilephone"]
    @me.language = params["language"]

    @me.student = is_student(params["email"])

    if not is_valid_domain(params["email"])
      flash[:error] = t('devise.sessions.wrong_domain')
      redirect_to "/profile"
    elsif not is_correct_account(params["email"], @me.username)
      flash[:error] = t('devise.sessions.wrong_email')
      redirect_to "/profile"
    else
      respond_to do |format|
        if @me.save
          format.html { redirect_to "/", notice: t('notices.successful_update', :model => User.model_name.human) }
          format.json { render :show }
        else
          format.html { render :new }
          format.json { render json: @me.errors, status: :unprocessable_entity }
        end
      end
    end
  end

  def is_valid_domain(email)
    domains = Rails.application.config.login["domains"]

    return (email && domains.include?(email.split('@').last))
  end

  def is_correct_account(email, username)
    return (email && username == email.split('@').first)
  end

  def is_student(email)
    email_domain = email.split('@').last

    if email_domain && email_domain.split('.').first == 'student'
      return true
    else
      return false
    end
  end
end
{'fraction_non_alphanumeric': 0.12281722933643772, 'fraction_numerical': 0.0, 'mean_word_length': 3.0578512396694215, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2748322', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1055, 'n_words': 229}