security issues : class

by Cristi Salcescu

JavaScript

class User {
		constructor(){
    		this.authorized = false;
    }
    
    isAuthorized(){
    		return this.authorized;
    }
}

const user = new User();
user.authorized = true;							//access to private property
user.isAuthorized = function() { return true; }		//redefine the public API
console.log(user.isAuthorized());		//true