1

我正在尝试使用 Ember Simple Auth 处理错误消息,我正在使用设计扩展。

文件:app/controllers/login.js

import Ember from 'ember';
import LoginControllerMixin from 'simple-auth/mixins/login-controller-mixin';

export default Ember.Controller.extend(LoginControllerMixin, {
  authenticator: 'simple-auth-authenticator:devise',
  identification: null,
  password: null,
  loginError: false,
  isSubmitting: false,

  actions: {
    authenticate: function() {
      var data = this.getProperties('identification', 'password');

      this._super(data);

      this.set('password', null);

      this.setProperties({
        loginError: true,
        loginResponse: 'login error'
      });
    }
  }
});

目前我总是收到错误消息。我不知道如何仅在发生错误时显示它。我试过了

this._super(data).then(function({
    // Error handler
});

但后来我收到错误“_super() 未定义”。

4

1 回答 1

2

在上面的代码中,无论登录是否成功,您总是设置错误。您需要做的是自己触发会话身份验证:

this.get('session').authenticate(this.get('authenticator'), data).then(function() {
  …//success
}, function(error) {
  …//error
});
于 2014-07-19T11:10:21.347 回答