Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs Ionic firebase登录验证不起作用(电子邮件)_Angularjs_Ionic_Firebase - Fatal编程技术网

Angularjs Ionic firebase登录验证不起作用(电子邮件)

Angularjs Ionic firebase登录验证不起作用(电子邮件),angularjs,ionic,firebase,Angularjs,Ionic,Firebase,使用登录/注销时,一切似乎都正常。但是,当我做一个初始的“爱奥尼亚服务”时,我会找到登录页面,但是如果我随后将url更改为“/menu/map”,我可以进入map.html,这应该是不可能的。单击我的“注销”按钮后也会发生同样的情况 我的身份验证码有什么问题? app.js angular.module('starter', ['ionic', 'firebase']) .config(function($ionicConfigProvider) { $ionicConfigProvider

使用登录/注销时,一切似乎都正常。但是,当我做一个初始的“爱奥尼亚服务”时,我会找到登录页面,但是如果我随后将url更改为“/menu/map”,我可以进入map.html,这应该是不可能的。单击我的“注销”按钮后也会发生同样的情况

我的身份验证码有什么问题?

app.js

angular.module('starter', ['ionic', 'firebase'])
.config(function($ionicConfigProvider) {
  $ionicConfigProvider.scrolling.jsScrolling(true);
})
.run(function($ionicPlatform, $rootScope, Auth, $state) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
    //stateChange event
      $rootScope.$on("$stateChangeStart", function(event, toState, toParams, fromState, fromParams){
      if (toState.authRequired && !Auth.isAuthenticated()){ //Assuming the AuthService holds authentication logic
        // User isn’t authenticated
        $state.go("login");
        event.preventDefault(); 
      }
    });
})
.config(function($stateProvider, $urlRouterProvider) {
  $stateProvider
      .state('login', {
        url: '/',
        templateUrl: 'templates/login/login.html',
        controller: 'userCtrl'
      })

      .state('app', {
        url: '/menu',
        abstract: true,
        templateUrl: 'templates/menu.html'
      })
      .state('app.map', {
        url: '/map',
        views: {
            'public-map': {
                templateUrl: 'templates/map.html',
                authRequired: true
            }
        }
      })
      $urlRouterProvider.otherwise("/");
})
.constant('FIREBASE_ROOT', 'https://<MYAPP>.firebaseio.com');
angular.module('starter')
.factory("Auth", function($firebaseAuth, FIREBASE_ROOT) {
  var usersRef = new Firebase(FIREBASE_ROOT);
  return $firebaseAuth(usersRef);
});
angular.module('starter')
.controller('userCtrl', function($scope, $state, Auth) {
    $scope.login = function(email, password) {
        Auth.$authWithPassword({
            email: email,
            password: password
        }).then(function(authData) {
            $state.go("app.map");
        }).catch(function(error) {
            console.error("ERROR: " + error);
        });
    };
     $scope.logout = function() {
          Auth.$unauth();
          $state.go("login");
     };
})
controller.js

angular.module('starter', ['ionic', 'firebase'])
.config(function($ionicConfigProvider) {
  $ionicConfigProvider.scrolling.jsScrolling(true);
})
.run(function($ionicPlatform, $rootScope, Auth, $state) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
    //stateChange event
      $rootScope.$on("$stateChangeStart", function(event, toState, toParams, fromState, fromParams){
      if (toState.authRequired && !Auth.isAuthenticated()){ //Assuming the AuthService holds authentication logic
        // User isn’t authenticated
        $state.go("login");
        event.preventDefault(); 
      }
    });
})
.config(function($stateProvider, $urlRouterProvider) {
  $stateProvider
      .state('login', {
        url: '/',
        templateUrl: 'templates/login/login.html',
        controller: 'userCtrl'
      })

      .state('app', {
        url: '/menu',
        abstract: true,
        templateUrl: 'templates/menu.html'
      })
      .state('app.map', {
        url: '/map',
        views: {
            'public-map': {
                templateUrl: 'templates/map.html',
                authRequired: true
            }
        }
      })
      $urlRouterProvider.otherwise("/");
})
.constant('FIREBASE_ROOT', 'https://<MYAPP>.firebaseio.com');
angular.module('starter')
.factory("Auth", function($firebaseAuth, FIREBASE_ROOT) {
  var usersRef = new Firebase(FIREBASE_ROOT);
  return $firebaseAuth(usersRef);
});
angular.module('starter')
.controller('userCtrl', function($scope, $state, Auth) {
    $scope.login = function(email, password) {
        Auth.$authWithPassword({
            email: email,
            password: password
        }).then(function(authData) {
            $state.go("app.map");
        }).catch(function(error) {
            console.error("ERROR: " + error);
        });
    };
     $scope.logout = function() {
          Auth.$unauth();
          $state.go("login");
     };
})

显然这是一个普遍的问题。爱奥尼亚团队增加了一些解决方法的说明;使用cordova白名单插件将您的域列入白名单


你可以在这里阅读所有关于它的内容:

显然这是一个常见的问题。爱奥尼亚团队增加了一些解决方法的说明;使用cordova白名单插件将您的域列入白名单

您可以在此处阅读所有相关内容: