Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.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
Ember.js 余烬:ESA:sessionAuthenticated不';我没打电话_Ember.js_Ember Simple Auth - Fatal编程技术网

Ember.js 余烬:ESA:sessionAuthenticated不';我没打电话

Ember.js 余烬:ESA:sessionAuthenticated不';我没打电话,ember.js,ember-simple-auth,Ember.js,Ember Simple Auth,我想在ember simple auth会话获得身份验证时执行一些代码 routes/application.js import Ember from 'ember'; import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin'; export default Ember.Route.extend(ApplicationRouteMixin, { currentUser: Em

我想在ember simple auth会话获得身份验证时执行一些代码

routes/application.js

import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';

export default Ember.Route.extend(ApplicationRouteMixin, {
    currentUser: Ember.inject.service('current-user'),
    ajax: Ember.inject.service('ajax'),

    actions: {
        authSuccess: function() {
            var self = this;
            self.get('ajax').request({
                url: "http://prod-drunkedguru.rhcloud.com/rest/users/me",
                method: "GET"
            }, function(response) {
                Ember.$('#loginWindow').modal('hide');
                self.get('currentUser').setUser(response);
            }, function(xhr, status, error) {
                if (status === "Incorrect credentials") {
                    self.set('hasError', true);
                }
            });

        }
    },

    sessionAuthenticated: function() {
        console.log("auth success!");
    },

    sessionInvalidated: function() {
        console.log("401");
    }
});
authoritators/digest.js

import Base from 'ember-simple-auth/authenticators/base';
import Ember from 'ember';
import CryptoJS from 'npm:crypto-js';

export default Base.extend({

    restore: function(data) {
        if (data.email && data.password) {
            return new Ember.RSVP.Promise(function(resolve, reject) {
                resolve({email: data.email, password: data.password, digests: {}});
            });
        }
    },

    authenticate: function(email, password) {
        var self = this;
        return new Ember.RSVP.Promise(function(resolve, reject) {
            Ember.run(function() {
                resolve({email: email, password: password, digests: {}});
            });
        });
    },

    invalidate: function(data) {
        //
    }
});
在应用程序启动时成功调用了
restore()
函数,并调用了其中的
resolve()
。我希望控制台中出现“auth success!”字符串,但什么也得不到。这是一个bug还是我的代码中的错误? 谢谢

更新:


经过一番调查,我意识到,
sessionAuthenticated
只被调用过一次。当使用方法
restore
从本地存储还原会话时,不会调用它。这是预期的行为吗?对我来说,它看起来像一个bug…

sessionAuthenticated和
sessionInvalidated
都是操作。只需将它们移动到
操作
散列中,就可以得到日志语句。

会话验证
会话验证
都是操作。只需将它们移动到
操作
散列中,就可以得到日志语句。

Thx。我试试看。但我认为这些都是方法(正如我从中学到的)。啊,这是从0.8.x到1.x的变化。抱歉弄脏了水。谢谢。我试试看。但我认为这些都是方法(正如我从中学到的)。啊,这是从0.8.x到1.x的变化。对不起,弄脏了水。