After successfully logging in and authenticating through Firebase, I am looking to direct users to a specific view.
app.controller('PageCtrl', function ($scope, $location, $http ) {
$scope.logIn = function(){
var email = $('#login-email').val();
var password = $('#login-password').val();
myDataRef.authWithPassword({
email : email,
password : password
}, function(error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
email = myDataRef.getAuth().password.email;
$('#userinfo').html(email);
$('#logoutButton').show();
$location.path('/form-success'); //route to success view
}
$location.path('/form-error'); //route to error view
});
}
}
How can I ensure that users are directed to a specific view after successful login and another view after unsuccessful login? Placing the routing logic inside the if...else block does not seem to be effective.