I created an entry system with corner fire and firebase.
I have a function that is called when the user logs in and several times. Checks if authData exists and registers the user as registered if one exists.
fbRef.onAuth(authDataCallback);
function authDataCallback(authData) {
if (authData) {
$scope.loggedIn = true;
} else {
$scope.loggedIn = false;
}
}
I also have routes installed
.config(function($routeProvider) {
$routeProvider
.when('/', {
controller: '',
templateUrl: '/company/pages/account/pages/dashboard.php',
})
.when('/dashboard', {
controller: '',
templateUrl: '/company/pages/account/pages/dashboard.php',
})
.when('/login', {
controller: 'Authorization',
templateUrl: '/company/pages/account/pages/login.php',
})
.when('/register', {
controller: 'Authorization',
templateUrl: '/company/pages/account/pages/register.php',
})
})
I want every page, except for the login and registration pages, to be limited only to enter the system. I want the user to be redirected to the login page if it $scope.loggedInreturns false.
I tried many solutions on the Internet, but no one worked for me. Most of them led to exceeding the limit.
How to restrict access in my situation?
source
share