<commit_before># Class: sessions_controller.rb.
# Purpose: This class is designed to control the actions of session within the Avalia Mais.
# Avalia Mais.
# FGA - Universidade de Brasíilia UnB.

class SessionsController < ApplicationController

	# Name: new
  # Objective: this method create a new instance of session on system.
  # Parameters: don't have parameters.
  # Return: redirect to home page.

	def new

		if(logged_in?)
			return redirect_to(home_path)
		else
			#nothing to do
		end

	end

	# Name: create
	# Objective: this method create a new session on system.
	# Parameters: user params.
	# Return: render a new page of logged user.

	def create

		user = find_user_record

		if(user && user.authenticate(params[:session][:password]))
			log_in(user)
			flash.now[:notice] = 'Login realizado com sucesso'
			return redirect_to(home_path)
		else
			flash.now[:notice] = 'Login ou senha inválidos'
			return render('new')
		end

	end

	# Name: destroy
	# Objective: this method destroy a session instance.
	# Parameters: user identifier.
	# Return: redirect to login page.

	def destroy

		session[:user_id] = nil
		flash.now[:notice] = 'Logout efetuado com sucesso'

		return redirect_to(home_path)

	end

	# Name: find_user_to_log
	# Objective: find user to log in system with your nickname or email.
	# Parameters: user identifier.
	# Return: redirect to login page.

	def find_user_to_log

		User.find_by(login: params[:session][:login]) || User.find_by(email: params[:session][:login])

	end

end
<commit_msg>Added encapsulation to param method<commit_after># Class: sessions_controller.rb.
# Purpose: This class is designed to control the actions of session within the Avalia Mais.
# Avalia Mais.
# FGA - Universidade de Bras<NAME>.

class SessionsController < ApplicationController

	# Name: new
  # Objective: this method create a new instance of session on system.
  # Parameters: don't have parameters.
  # Return: redirect to home page.

	def new

		if(logged_in?)
			return redirect_to(home_path)
		else
			#nothing to do
		end

	end

	# Name: create
	# Objective: this method create a new session on system.
	# Parameters: user params.
	# Return: render a new page of logged user.

	def create

		user = find_user_record

		if(user && user.authenticate(params[:session][:password]))
			log_in(user)
			flash.now[:notice] = 'Login realizado com sucesso'
			return redirect_to(home_path)
		else
			flash.now[:notice] = 'Login ou senha inválidos'
			return render('new')
		end

	end

	# Name: destroy
	# Objective: this method destroy a session instance.
	# Parameters: user identifier.
	# Return: redirect to login page.

	def destroy

		session[:user_id] = nil
		flash.now[:notice] = 'Logout efetuado com sucesso'

		return redirect_to(home_path)

	end

	# Name: find_user_to_log
	# Objective: find user to log in system with your nickname or email.
	# Parameters: user identifier.
	# Return: redirect to login page.

	private

	def find_user_to_log

		User.find_by(login: params[:session][:login]) || User.find_by(email: params[:session][:login])

	end

end

{'fraction_non_alphanumeric': 0.09011345218800648, 'fraction_numerical': 0.0, 'mean_word_length': 3.9534510433386836, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, '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': '806948', 'n_tokens_mistral': 1063, 'n_tokens_neox': 952, 'n_words': 336}