<commit_before>package ca.corefacility.bioinformatics.irida.ria.web;

import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import ca.corefacility.bioinformatics.irida.ria.web.projects.ProjectsController;
import ca.corefacility.bioinformatics.irida.service.EmailController;

/**
 */
@Controller
public class LoginController extends BaseController {
	private static final Logger logger = LoggerFactory.getLogger(LoginController.class);
	private static final String LOGIN_PAGE = "login";
	
	
	private final EmailController emailController;
	
	@Autowired
	public LoginController(final EmailController emailController) {
		this.emailController = emailController;
	}

	@RequestMapping(value = "/")
	public String showSplash() {
		return "forward:/dashboard";
	}

	@RequestMapping(value = "/login")
	public String showLogin(Model model,
			@RequestParam(value = "error", required = false, defaultValue = "false") Boolean hasError,
			@RequestParam(value="galaxyCallbackUrl",required=false) String galaxyCallbackURL,
			@RequestParam(value="galaxyClientID",required=false) String galaxyClientID,
			HttpSession httpSession) {
		logger.debug("Displaying login page.");
		
		model.addAttribute("emailConfigured", emailController.isMailConfigured());
		
		//External exporting functionality
		if(galaxyCallbackURL != null && galaxyClientID !=null) {
			httpSession.setAttribute(ProjectsController.GALAXY_CALLBACK_VARIABLE_NAME, galaxyCallbackURL);
			httpSession.setAttribute(ProjectsController.GALAXY_CLIENT_ID_NAME, galaxyClientID);
		}
	
		model.addAttribute("error", hasError);
		return LOGIN_PAGE;
	}
}
<commit_msg>Redirect user if already logged in<commit_after>package ca.corefacility.bioinformatics.irida.ria.web;

import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import ca.corefacility.bioinformatics.irida.ria.web.projects.ProjectsController;
import ca.corefacility.bioinformatics.irida.service.EmailController;

/**
 */
@Controller
public class LoginController extends BaseController {
	private static final Logger logger = LoggerFactory.getLogger(LoginController.class);
	private static final String LOGIN_PAGE = "login";


	private final EmailController emailController;

	@Autowired
	public LoginController(final EmailController emailController) {
		this.emailController = emailController;
	}

	@RequestMapping(value = "/")
	public String showSplash() {
		return "forward:/dashboard";
	}

	@RequestMapping(value = "/login")
	public String showLogin(Model model,
			@RequestParam(value = "error", required = false, defaultValue = "false") Boolean hasError,
			@RequestParam(value="galaxyCallbackUrl",required=false) String galaxyCallbackURL,
			@RequestParam(value="galaxyClientID",required=false) String galaxyClientID,
			HttpSession httpSession) {

		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
		if (!(auth instanceof AnonymousAuthenticationToken)) {
			logger.debug("User is already logged in.");
			return "forward:/dashboard";
		}

		logger.debug("Displaying login page.");

		model.addAttribute("emailConfigured", emailController.isMailConfigured());

		//External exporting functionality
		if(galaxyCallbackURL != null && galaxyClientID !=null) {
			httpSession.setAttribute(ProjectsController.GALAXY_CALLBACK_VARIABLE_NAME, galaxyCallbackURL);
			httpSession.setAttribute(ProjectsController.GALAXY_CLIENT_ID_NAME, galaxyClientID);
		}

		model.addAttribute("error", hasError);
		return LOGIN_PAGE;
	}
}

{'fraction_non_alphanumeric': 0.10020925366193909, 'fraction_numerical': 0.0009300162752848175, 'mean_word_length': 6.641207815275311, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3023839', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1166, 'n_words': 223}