<commit_before>package br.com.caelum.brutal.controllers;

import java.util.Arrays;

import br.com.caelum.brutal.auth.DefaultAuthenticator;
import br.com.caelum.vraptor.Get;
import br.com.caelum.vraptor.Post;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;

@Resource
public class AuthController {
	
	private final DefaultAuthenticator auth;
	private final Result result;
	public AuthController(DefaultAuthenticator auth, Result result) {
		this.auth = auth;
		this.result = result;
	}
	
	@Get("/login")
	public void loginForm(){
	}
	
	@Post("/login")
	public void login(String email, String password, String redirectUrl) {
		if (auth.authenticate(email, password)) {
			redirectToRightUrl(redirectUrl);
		} else {
			result.include("invalid_login", true);
			result.include("alerts", Arrays.asList("auth.invalid.login"));
			result.redirectTo(ListController.class).home();
		}
	}
	
	@Get("/logout")
	public void logout() {
		auth.signout();
		result.redirectTo(ListController.class).home();
	}
	<commit_msg>redirecionando para formulario de login quando der erro<commit_after>package br.com.caelum.brutal.controllers;

import java.util.Arrays;

import br.com.caelum.brutal.auth.DefaultAuthenticator;
import br.com.caelum.vraptor.Get;
import br.com.caelum.vraptor.Post;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;

@Resource
public class AuthController {
	
	private final DefaultAuthenticator auth;
	private final Result result;
	public AuthController(DefaultAuthenticator auth, Result result) {
		this.auth = auth;
		this.result = result;
	}
	
	@Get("/login")
	public void loginForm(){
	}
	
	@Post("/login")
	public void login(String email, String password, String redirectUrl) {
		if (auth.authenticate(email, password)) {
			redirectToRightUrl(redirectUrl);
		} else {
			result.include("invalid_login", true);
			result.include("alerts", Arrays.asList("auth.invalid.login"));
			result.redirectTo(this).loginForm();
		}
	}
	
	@Get("/logout")
	public void logout() {
		auth.signout();
		result.redirectTo(ListController.class).home();
	}
	
{'fraction_non_alphanumeric': 0.13089005235602094, 'fraction_numerical': 0.0, 'mean_word_length': 4.92112676056338, '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': '6440232', 'n_tokens_mistral': 753, 'n_tokens_neox': 712, 'n_words': 135}