<commit_before><?php

class LoginController extends BaseController {

	public function getIndex() {
        $success = Session::get('success');
        if($success == 'email-confirmation::messages.confirmed' || $success == 'Your email is confirmed'){
            Event::fire('logger',array(array('email_confirmation','',2)));
        }

		return View::make('login.index');
	}

	public function postIndex() {
		$input = Input::only('username', 'password', 'remember');

		$rules = array(
			'username' => 'required|min:3',
			'password'  => '<PASSWORD>',
		);
		$v = Validator::make($input, $rules);
		if ($v->fails()) {
			return Output::push(array('path' => 'login', 'errors' => $v));
		}

		// check login with username
		if (Auth::attempt(array('username' => $input['username'], 'password' => $input['password']), $input['remember'])) {
			//check ban status
			if (Auth::user()->flag_banned == 1){
	    			Auth::logout();
				return Output::push(array(
					'path' => 'login',
					'messages' => array('fail' => _('You are banned'))
					));
			}
            //set cookie domain hash
            if(Auth::user()->status == 4){
                Cookie::queue('domain_hash',Auth::user()->domain_id);
            }
			return Output::push(array(
				'path' => 'dashboard',
				'messages' => array('success' => _('You have successfully logged in'))
				));
		}

		// try again this time with email address as username
		if (Auth::attempt(array('email' => $input['username'], 'password' => $input['password']), $input['remember'])) {
			//check ban status
			if (Auth::user()->ban == 1){
	    			Auth::logout();
				return Output::push(array(
					'path' => 'login',
					'messages' => array('fail' => _('You are banned'))
					));
			}
            //set cookie domain hash
            if(Auth::user()->status == 4){
                Cookie::queue('domain_hash',Auth::user()->domain_id);
            }
			return Output::push(array(
				'path' => 'dashboard',
				'messages' => array('success' => _('You have successfully logged in'))
				));
		} else {
            Event::fire('logger', array(array('login_failed',array('username'=>$input['username']),3)));
			return Output::push(array(
				'path' => 'login',
				'messages' => array('fail' => _('Invalid username or password'))
				));
		}
	}

	public function getLogout() {
		Auth::logout();
		return Output::push(array(
			'path' => 'login',
			'messages' => array('success' => _('You have been logged out'))
			));
	}

}<commit_msg>Fix domain cookie remain when admin/manager login<commit_after><?php

class LoginController extends BaseController {

	public function getIndex() {
        $success = Session::get('success');
        if($success == 'email-confirmation::messages.confirmed' || $success == 'Your email is confirmed'){
            Event::fire('logger',array(array('email_confirmation','',2)));
        }

		return View::make('login.index');
	}

	public function postIndex() {
		$input = Input::only('username', 'password', 'remember');

		$rules = array(
			'username' => 'required|min:3',
			'password'  => '<PASSWORD>',
		);
		$v = Validator::make($input, $rules);
		if ($v->fails()) {
			return Output::push(array('path' => 'login', 'errors' => $v));
		}

		// check login with username
		if (Auth::attempt(array('username' => $input['username'], 'password' => $input['password']), $input['remember'])) {
			//check ban status
			if (Auth::user()->flag_banned == 1){
	    			Auth::logout();
				return Output::push(array(
					'path' => 'login',
					'messages' => array('fail' => _('You are banned'))
					));
			}
            //set cookie domain hash
            if(Auth::user()->status == 4){
                $cookie = Cookie::make('domain_hash',Auth::user()->domain_id);
            }else{
                $cookie = Cookie::forget('domain_hash');
            }
            return Redirect::to('dashboard')->with('success', _('You have successfully logged in'))->withCookie($cookie);
		}

		// try again this time with email address as username
		if (Auth::attempt(array('email' => $input['username'], 'password' => $input['password']), $input['remember'])) {
			//check ban status
			if (Auth::user()->ban == 1){
	    			Auth::logout();
				return Output::push(array(
					'path' => 'login',
					'messages' => array('fail' => _('You are banned'))
					));
			}
            //set cookie domain hash
            if(Auth::user()->status == 4){
                $cookie = Cookie::make('domain_hash',Auth::user()->domain_id);
            }else{
                $cookie = Cookie::forget('domain_hash');
            }
            return Redirect::to('dashboard')->with('success', _('You have successfully logged in'))->withCookie($cookie);
		} else {
            Event::fire('logger', array(array('login_failed',array('username'=>$input['username']),3)));
			return Output::push(array(
				'path' => 'login',
				'messages' => array('fail' => _('Invalid username or password'))
				));
		}
	}

	public function getLogout() {
		Auth::logout();
		return Output::push(array(
			'path' => 'login',
			'messages' => array('success' => _('You have been logged out'))
			));
	}

}
{'fraction_non_alphanumeric': 0.20580218068535824, 'fraction_numerical': 0.0027258566978193145, 'mean_word_length': 3.169642857142857, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 71, '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': '1865595', 'n_tokens_mistral': 1745, 'n_tokens_neox': 1513, 'n_words': 334}