我試圖實現燼一個認證系統具有以下版本:認證使用的餘燼,簡單的auth-裝置和後軌後端
DEBUG: -------------------------------
ember.debug.js:5378 DEBUG: Ember : 1.13.7
ember.debug.js:5378 DEBUG: Ember Data : 1.13.8
ember.debug.js:5378 DEBUG: jQuery : 1.11.3
ember.debug.js:5378 DEBUG: Ember Simple Auth : 0.8.0
ember.debug.js:5378 DEBUG: Ember Simple Auth Devise : 0.8.0
ember.debug.js:5378 DEBUG: -------------------------------
我跟着GitHub上的指示https://github.com/simplabs/ember-simple-auth/tree/master/packages/ember-simple-auth-devise
現在當我打「註冊」它返回一個500錯誤:
POST http://localhost:4200/users/sign_in 500 (Internal Server Error)
我覺得應該去到localhost:3000 /用戶/ sign_in,但事實並非如此。
我用ember s --proxy http://localhost:3000
命令啓動了服務器,但不明白髮生了什麼。
這裏是我的參考代碼:
控制器/ 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'
});
路線/ login.js
import Ember from 'ember';
import UnauthenticatedRouteMixin from 'simple-auth/mixins/unauthenticated-route-mixin';
export default Ember.Route.extend(UnauthenticatedRouteMixin);
模板/ application.hbs
<h2 id="title">Welcome to Ember.js - With Authentication!</h2>
{{#if session.isAuthenticated}}
Hi, {{session.email}}
<br/>
You can't see this text unless you're logged in!
<br/>
Click this button to logout:
<button {{action 'invalidateSession'}}>Logout</button>
<br/>
If you try to go to the
{{#link-to "login"}}Login{{/link-to}}
page, you should get redirected!
{{else}}
{{#link-to "login"}}Login{{/link-to}}
{{/if}}
{{outlet}}
templates/login.hbs
<form {{action "authenticate" on="submit"}}>
<div>
<label for="identification">E-mail</label><br />
{{input value=identification placeholder="E-mail" type="text" name="email"}}
</div>
<div>
<label for="password">Password</label><br />
{{input value=password placeholder="Password" type="password" name="password"}}
</div>
<div>
<button type="submit">Log in</button>
</div>
</form>
配置/ environment.js
...
ENV['simple-auth'] = {
authorizer: 'simple-auth-authorizer:devise'
}
ENV['simple-auth-devise'] = {
tokenAttributeName: 'token',
identificationAttributeName: 'email'
}
...
我的軌道路線是這樣的:
devise_for :users, controllers: { sessions: 'sessions' }
請求是否到達Rails後端? – marcoow
yes,它返回'ActionController :: RoutingError(沒有路由匹配[POST]「/ users/sign_in」):'(在上面添加了我的設計路線) –
這意味着'/ users/sign_in'路線沒有配置在Rails應用程序中,這是500錯誤 – marcoow