<commit_before>const Resources = require('../Resources').default;
const User = require('./user').default;     
let dataUsers = require('../../data/users'); // Simulate data of database
const jwt = require('jsonwebtoken');
const GeneralConfig = require('../../config');

class Users extends Resources {

	constructor() {
		super();
		this._list = [];
		for(let user of dataUsers)
			this._list.push(new User(user));
	}

	login(email,password){
        // find user in array
        let arruser = dataUsers.filter(u => {
          let hash = User.hasfOfPassword(password);
          if(u.email === email && User.compareSyncPassword(password, u.password)) return u
        }); 
        let user = arruser[0] || {};
        let token;
        if(user.password) delete user.password;
        if(user.id != undefined)
          token = jwt.sign({ userId: user.id }, GeneralConfig.privateKey, { algorithm: 'HS256'});
        else
          token = false;
      	return { user: user, token: token};
	}

	list(){
		return this._list;
	}


	validate(userId){
		return dataUsers.filter(u => { if(u.id == userId) return u });
	}

	detail(id){
		let usersF = dataUsers.filter(u => { if(u.id == id) return u });
		return usersF.length < 1 ? false : new User(usersF[0]);
	}

	save(props){
		try{
			dataUsers.push(new User(props));
			return dataUsers[dataUsers.length - 1];
		}catch(err){
			return false;
		}
	}

	update(){

	}

	delete(){

	}

}

exports.default = Users;<commit_msg>Tabs to spaces<commit_after>const Resources = require('../Resources').default;
const User = require('./user').default;     
let dataUsers = require('../../data/users'); // Simulate data of database
const jwt = require('jsonwebtoken');
const GeneralConfig = require('../../config');

class Users extends Resources {

    constructor() {
        super();
        this._list = [];
        for(let user of dataUsers)
            this._list.push(new User(user));
    }

    login(email,password){
        // find user in array
        let arruser = dataUsers.filter(u => {
          let hash = User.hasfOfPassword(password);
          if(u.email === email && User.compareSyncPassword(password, u.password)) return u
        }); 
        let user = arruser[0] || {};
        let token;
        if(user.password) delete user.password;
        if(user.id != undefined)
          token = jwt.sign({ userId: user.id }, GeneralConfig.privateKey, { algorithm: 'HS256'});
        else
          token = false;
          return { user: user, token: token};
    }

    list(){
        return this._list;
    }


    validate(userId){
        return dataUsers.filter(u => { if(u.id == userId) return u });
    }

    detail(id){
        let usersF = dataUsers.filter(u => { if(u.id == id) return u });
        return usersF.length < 1 ? false : new User(usersF[0]);
    }

    save(props){
        try{
            dataUsers.push(new User(props));
            return dataUsers[dataUsers.length - 1];
        }catch(err){
            return false;
        }
    }

    update(){

    }

    delete(){

    }

}

exports.default = Users;
{'fraction_non_alphanumeric': 0.1546925566343042, 'fraction_numerical': 0.004530744336569579, 'mean_word_length': 2.3308189655172415, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2224155', 'n_tokens_mistral': 971, 'n_tokens_neox': 925, 'n_words': 225}