0

現在$on('angularFireAuth:login', function(evt,auth){...get other profile info...})、ログイン後にユーザーのプロファイルと承認の詳細を入力するために を使用しています。そのようなものは、後でアプリ全体で簡単にアクセスできるように authService に追加されます$rootscope。問題は、これが更新または再開時にトリガーされないことです。ユーザーはセッション トークンなどによって認証されたままですが、他のプロファイルを読み込むには再ログインする必要があります。

これに対する適切な解決策は何ですか?ログインの代わりに使用すべき文書化されていないイベントはありますか?

私が使用している app.js は次のとおりです。

angular.module('myApp',['firebase']).
    constant({FirebaseUrl:"https://<foo>.firebaseio.com/"}).
    service('authService', function authService(){
        return {
            isLogged:false,
            name:null,
            email:null,
            id:null,
            group:null,
            err:null
        }
    }).
    controller('AuthCtrl', function($scope, authService, angularFireAuth, angularFireCollection, FirebaseUrl){
        angularFireAuth.initialize(FirebaseUrl, {scope:$scope, name:"auth"});
        $scope.login = function(){
            angularFireAuth.login('password', {
                email: 'test@test.foo',
                password: 'test'
                });
        }
        $scope.$on("angularFireAuth:login",function(evt,auth){
            url = FirebaseUrl + 'profiles/user-' + $scope.auth.id;
            $scope.url = url;
            var fbref = new Firebase(url);
            fbref.once('value',function(profileSnapshot){
                $scope.name = profileSnapshot.child('name').val();
                $scope.group = profileSnapshot.child('group').val();
            });
            //set authService stuff
            authService.name = $scope.name;
            authService.group = $scope.group;
            authService.email = $scope.auth.email;
            authService.id = $scope.auth.id;
            authService.isLogged = true;
        });

        $scope.logout = function(){
            angularFireAuth.logout();
            authService.email = null;
            authService.id = null;
            authService.isLogged = false;
            authService.name = null;
            authService.group = null;
        }
    }).
    controller('NavCtrl', function($scope, authService){

    });
4

1 に答える 1