<commit_before>import axios from 'axios'

let auth = {
	login(user, callback){
		if (this.loggedIn()){
			callback(true);
			return;
		}
		axios.post('/sessions', user).then((res) => {
			if (res.data.authenticated) {
				// localStorage.token = res.data.token
				localStorage.id = res.data.id
				console.log(localStorage.id)
				callback(true)
			} else {
				callback(false, res.data.error)
			}
		})
	},

	getUser(id){
		return axios.get('/users/' + id)
	},

	loggedIn(){
		return !!localStorage.token
	},

	logout(callback){
		axios.delete('/sessions').then((res) => {
			if (res.data.err) {
				callback(false)
			} else {
				localStorage.clear()
				callback(true)
			}
		})
	},

	register(data, type, callback) {
		axios.post('/' + type, data).then((res) => {
			this.login(res.data, callback)
		})
	}
}

export default auth<commit_msg>Add correct routing for auth<commit_after>import axios from 'axios'

let auth = {
	login(user, callback){
		if (this.loggedIn()){
			callback(true);
			return;
		}
		axios.post('/sessions', user).then((res) => {
			if (res.data.authenticated) {
				localStorage.token = res.data.token
				localStorage.id = res.data.user.id
				if (callback) callback(true);
			} else {
				callback(false, res.data.error)
			}
		})
	},

	getUser(id, callback){
		axios.get('/users/' + id).then((res) => {
			callback(res.data)
		})
	},

	loggedIn(){
		return !!localStorage.token
	},

	logout(callback){
		axios.delete('/sessions').then((res) => {
			if (res.data.err) {
				callback(false)
			} else {
				localStorage.clear()
				callback(true)
			}
		})
	},

	register(data, type, callback) {
		axios.post('/' + type, data).then((res) => {
			this.login(res.data.user, callback)
		})
	}
}

export default auth
{'fraction_non_alphanumeric': 0.18369690011481057, 'fraction_numerical': 0.0, 'mean_word_length': 3.0534883720930233, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '1166235', 'n_tokens_mistral': 762, 'n_tokens_neox': 646, 'n_words': 107}