I'm a newbie and I just wanted to ask, that is there any way, to protect your angular variables/properties?
Like I have a One Page Application with authentication from client and server side. For the simple example I have 2 user type: Simple user and Admin.
Here is a basic ng-view:
<div class="container">
<div class="admin-view" ng-show="isAdmin">
.
.
</div>
<div class="user-view" ng-show="!isAdmin">
.
.
</div>
</div>
in my app.js
app.run(function($rootScope,$route, $http){
var user = {};
$rootScope.isAdmin = false;
$rootScope.getUser = function(){
$http({
methop: 'GET',
url: getMyUserPlease(...)
}).then(function successCallback(response){
user = response;
if (user.role === 'admin'){
$rootScope.isAdmin = true;
} else {
$rootScope.isAdmin = false;
}
})
}
})
It is working right, but if I inspect that in the browsers console, I can set the isAdmin property to true and i can see all the content that i couldn't have to see.
just type these in the browser console:
$rootScope = angular.element(document).scope();
$rootScope.isAdmin = true;
$rootScope.$apply();
Are there any good practice, to protect the "content"?
Thank you