{"size": 809, "ext": "js", "max_stars_repo_path": "resources/js/auth.js", "max_stars_repo_name": "hafijur2584/eCommerce_with_Laravel_Vue", "max_stars_repo_stars_event_min_datetime": "2020-02-16T11:55:20.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T06:24:32.000Z", "max_issues_repo_path": "resources/js/auth.js", "max_issues_repo_name": "hafijur2584/eCommerce_with_Laravel_Vue", "max_issues_repo_issues_event_min_datetime": "2021-03-09T13:08:58.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T15:47:20.000Z", "max_forks_repo_path": "resources/js/auth.js", "max_forks_repo_name": "hafijur2584/eCommerce_with_Laravel_Vue", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 4, "max_forks_count": null, "avg_line_length": 17.5869565217, "max_line_length": 54, "alphanum_fraction": 0.6440049444}
export default function(Vue){
	Vue.auth = {
		//set token
		setToken(token,expiration){
			localStorage.setItem('token',token)
			localStorage.setItem('expiration',expiration)
		},

		//get token
		getToken(){
			var token = localStorage.getItem('token')
			var expiration = localStorage.getItem('expiration')
			if (!token || !expiration)
				return null
			if (Date.now() > parseInt(expiration)) {
				this.destroyToken()
				return null
			}
			else
				return token

		},

		//destroy token
		destroyToken(){
			localStorage.removeItem('token')
			localStorage.removeItem('expiration')
		},

		//isAuthenticated
		isAuthenticated(){
			if(this.getToken())
				return true
			else
				return false	
		}
	}
	Object.defineProperties(Vue.prototype,{
		$auth:{
			get:() =>{
				return Vue.auth
			}
		}
	})

}