Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.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
Authentication 余烬简单授权设计给出错误';无法读取属性';验证';未定义的';Rails 4后端_Authentication_Ruby On Rails 4_Ember.js_Devise - Fatal编程技术网

Authentication 余烬简单授权设计给出错误';无法读取属性';验证';未定义的';Rails 4后端

Authentication 余烬简单授权设计给出错误';无法读取属性';验证';未定义的';Rails 4后端,authentication,ruby-on-rails-4,ember.js,devise,Authentication,Ruby On Rails 4,Ember.js,Devise,我正在使用Ember.SimpleAuth和designe的包。我以前曾多次使用Desive和rails,但我对ember还很陌生。此外,我开始怀疑我是否应该放弃设计带有令牌身份验证的余烬应用程序……无论如何,这是我的代码 更新 我注意到两件具体的事情: 我已经清理了我的资产,正在使用最新的ember-simple-auth.js。我似乎没有authenticatorFactory,因为以下行在“var会话”定义中是“未定义的”: _this.container.lookup(authentic

我正在使用Ember.SimpleAuth和designe的包。我以前曾多次使用Desive和rails,但我对ember还很陌生。此外,我开始怀疑我是否应该放弃设计带有令牌身份验证的余烬应用程序……无论如何,这是我的代码

更新

我注意到两件具体的事情:

  • 我已经清理了我的资产,正在使用最新的ember-simple-auth.js。我似乎没有authenticatorFactory,因为以下行在“var会话”定义中是“未定义的”:

    _this.container.lookup(authenticatorFactory)
    
  • 我觉得我应该调用ember-simple-auth-designe.js中的authenticate方法,但根据我的控制台,该文件从未被触动过。应该是这样吗

  • 结束更新


    我很确定我正确地遵循了指示:

    application.js:

    //= require jquery
    //= require jquery_ujs
    //= require handlebars
    //= require ember
    //= require ember-data
    //= require quiz
    //= require pen
    //= require ember-simple-auth
    //= require ember-simple-auth-devise
    //= require_self
    //= require quizzmob
    Quizzmob = Ember.Application.create({
        LOG_TRANSITIONS: true
    });
    
    初始化器/authentication.js.coffee

    Ember.Application.initializer
      name: "authentication"
      initialize: (container, application) ->
        Ember.SimpleAuth.setup container, application,
          authorizerFactory: 'ember-simple-auth-authorizer:devise'
    
    我为登录定义了一个路由:

    @route "login"
    
    以及控制器:

    Quizzmob.LoginController = Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin,
        authenticatorFactory: "ember-simple-auth-authenticator:devise"
    )
    
    以及我的登入表格:

    <form {{action 'authenticate' on='submit'}}>
      <label for="identification">Login</label>
        {{input id='identification' placeholder='Enter Login' value=identification}}
      <label for="password">Password</label>
        {{input id='password' placeholder='Enter Password' type='password' value=password}}
      <button type="submit">Login</button>
    </form>
    

    绝对没有向服务器发送请求,因此我认为我的ember设置有问题。

    身份验证器注册为
    ember simple auth authenticator:Deviate
    ,而不是
    ember simple auth authenticators:Deviate
    (不带“s”)。

    我在ember CLI中也有同样的错误,我在Brocfile.js中添加了以下内容:

    app.import('vendor/ember-simple-auth/ember-simple-auth.js');                     
    app.import('vendor/ember-simple-auth/ember-simple-auth-devise.js');
    
    保存并重新启动服务器

    ember server
    

    因此,请确保您包括
    ember simple auth designe.js
    ,并且正在重新启动服务器。

    创建
    login.js
    控制器,
    ember g控制器登录
    并在其中添加身份验证代码

    ember server
    
    /controller/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'
    });
    

    很抱歉,我一开始确实没有“s”,但得到了相同的错误。在查看了源代码之后,我做了一个实验来修改它。非常感谢您的回复。我现在就把它改回来。我添加了一个更新,可能会帮助您更轻松地诊断我的问题。您是否确保有最新版本的ember simple auth和ember simple auth Desive?是的。ember simple auth rails演示()适合我。我不确定ember simple auth Deave软件包中是否存在问题,或者我的设置/gemfile/bower/其他依赖项是否存在问题。我还没有尝试将Deave与ember simple auth rails演示一起使用,但当我尝试时,我会让你知道这是如何进行的。你能稍微调试一下并确保Desive扩展的初始值设定项实际上被调用了吗: