Here is my scenario:
- The user did not log in and tried to access the settings / settings page.
- My Settings controller recognizes based on
$auth.isAuthenticated() != true that they are not logged in, and redirects them to / login - The user fills in their email messages and passwords and sends them.
What I would like to do in this third step then redirects them to the / settings page, and not to the home page.
I think I would change this variable:
$authProvider.loginRedirect = '/';
The problem is that I cannot include $authProvider in my loginCtrl.js file without getting the "unknown provider" error in my console: https://docs.angularjs.org/error/ $ injector / unpr? p0 = In other words, Angular does not recognize $authProvider when I try to enable it. This is what my loginCtrl.js file looks like:
angular.module("PrayerChain") .controller("loginCtrl", ["$rootScope", "$scope", "$state", "$http", "$auth", "$authProvider", loginCtrl]); function loginCtrl($rootScope, $scope, $state, $http, $auth, $authProvider) { $authProvider.loginRedirect = '/settings'; $scope.login = function () { $auth.login({ Email: $scope.email, Password: $scope.password }) .then(function() { }) .catch(function (response, status, headers) { console.log(response); $scope.error = JSON.parse(response.data); }); }; }
Includes $authProvider in the controller even possible? If not, what is the alternative change solution when people are redirected when they log in using Satellizer?
Thanks.
source share