<commit_before><?php
class User implements JsonSerializable {
    private $id;
    private $name;
    private $permissions;
    private $userCampaignData;
    private $email;
    
    function __construct($id, $name, $email = null, $permissions = null, $userCampaignData = null) {
        $this->id = $id;
        $this->name = $name;
        $this->email = $email;
        $this->permissions = $permissions;
        $this->userCampaignData = $userCampaignData;
    }
        
    public function getId() {
        return $this->id;
    }
    
    public function jsonSerialize() {
        return array(
            "Id" => $this->id, 
            "Name" => $this->name, 
            "Permissions" => $this->permissions,
            "UserCampaignData" => $this->userCampaignData,
            "Email" => $this->email
        );
    }
    
    public function hasPermission($permissionId) {
        foreach($this->permissions as $permission) {
            if($permission->Id === $permissionId)
                return true;
        }
        
        return false;
    }
        
    public function setEmail($email) {
        $this->email = $email;
    }
    
    public static function setLoggedIn($user) {
        $expiry = time() + 60*60*24*30;
        
        setcookie("loggedInUserId", $user->id, $expiry, "/");
    }
    
    public static function getCurrentUser() {
        if(!isset($_COOKIE["loggedInUserId"]))
            return null;
        
        $userId = $_COOKIE["loggedInUserId"];
        
        if(!isset($_SESSION["user"]))
            $_SESSION["user"] = UserMapper::getUserById($userId);
        
        return $_SESSION["user"];
    }
    
    public static function isLoggedIn() {
        return isset($_COOKIE["loggedInUserId"]) ? true : false;
    }
    
    public static function logout() {
        setcookie("loggedInUserId", "", time() - 3600, "/");
        $_SESSION["user"] = null;
    }
}
?><commit_msg>Should be able to log in on the first try now.<commit_after><?php
class User implements JsonSerializable {
    private $id;
    private $name;
    private $permissions;
    private $userCampaignData;
    private $email;
    
    function __construct($id, $name, $email = null, $permissions = null, $userCampaignData = null) {
        $this->id = $id;
        $this->name = $name;
        $this->email = $email;
        $this->permissions = $permissions;
        $this->userCampaignData = $userCampaignData;
    }
        
    public function getId() {
        return $this->id;
    }
    
    public function jsonSerialize() {
        return array(
            "Id" => $this->id, 
            "Name" => $this->name, 
            "Permissions" => $this->permissions,
            "UserCampaignData" => $this->userCampaignData,
            "Email" => $this->email
        );
    }
    
    public function hasPermission($permissionId) {
        foreach($this->permissions as $permission) {
            if($permission->Id === $permissionId)
                return true;
        }
        
        return false;
    }
        
    public function setEmail($email) {
        $this->email = $email;
    }
    
    public static function setLoggedIn($user) {
        $expiry = time() + 60*60*24*30;
        
        setcookie("loggedInUserId", $user->id, $expiry, "/");
        $_SESSION["isLoggedIn"] = true;
    }
    
    public static function getCurrentUser() {
        if(!isset($_COOKIE["loggedInUserId"]))
            return null;
        
        $userId = $_COOKIE["loggedInUserId"];
        
        if(!isset($_SESSION["user"]))
            $_SESSION["user"] = UserMapper::getUserById($userId);
        
        return $_SESSION["user"];
    }
    
    public static function isLoggedIn() {
        if(isset($_SESSION["isLoggedIn"]))
            return $_SESSION["isLoggedIn"];
        
        return isset($_COOKIE["loggedInUserId"]) ? true : false;
    }
    
    public static function logout() {
        setcookie("loggedInUserId", "", time() - 3600, "/");
        $_SESSION["user"] = null;
        $_SESSION["isLoggedIn"] = false;
    }
}
?>
{'fraction_non_alphanumeric': 0.14173998044965788, 'fraction_numerical': 0.005865102639296188, 'mean_word_length': 1.9919590643274854, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '3555711', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1209, 'n_words': 241}