【问题标题】:ember-cli-simple-auth-devise not sending the right attributesember-cli-simple-auth-devise 未发送正确的属性
【发布时间】:2015-05-03 10:01:05
【问题描述】:

我正在尝试让 ember-cli-simple-auth-devise 工作。我已经按照https://github.com/simplabs/ember-simple-auth/tree/master/packages/ember-simple-auth-devise 的要求对 Rails 进行了修改,但我发现 emberjs 发送了错误的属性:account[identification] 和 account[password] 而不是 user[email] 和 user[password]。

我变了

ENV['simple-auth-devise'] = {
  resourceName: 'account'
};

ENV['simple-auth-devise'] = {
  resourceName: 'user'
};

和 login.hbs 包含:

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

以便表单生成一个名为电子邮件的表单字段,而不是标识。在控制器中:

export default Ember.Controller.extend({
    actions: {
        authenticate: function() {
            var data = this.getProperties('email', 'password');
            return this.get('session').authenticate('simple-auth-authenticator:devise', data);
        }
    }
});

data 有我想要的:

{email: "email@address.com", password: "supersecret"}

但只有 Rails

{"user"=>{"password"=>"supersecret"},
 "controller"=>"sessions",
 "action"=>"create"}"

电子邮件丢失。如何让电子邮件到达 Rails?

【问题讨论】:

    标签: ember.js devise


    【解决方案1】:

    识别表单字段应保留为识别,因为它会在调用设计时自动转换为电子邮件。名称的转换根据identificationAttributeName configuration 进行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-09
      • 1970-01-01
      相关资源
      最近更新 更多