私はDRFトークンに対して認証しようとしています。emberjsコンポーネントフォームアクション
作成した認証アプリケーションを使用してログインできました。
私は滑らかになり、ログインフォームをコンポーネントにすると思っていました。
しかし、私はログインすることができないので、Assertion failure
を取得します。
マイテンプレート/コンポーネント/ AUTH-login.hbsテンプレートはそうのように見える...
<form class='navbar-form navbar-right' {{action 'authenticate' on='submit'}}>
<div class="form-group">
{{input id='identification' placeholder='Username' type='text' class='form-control' value=identification}}
{{input id='password' placeholder='Password' type='password' class='form-control' value=password}}
</div>
<button type="submit">Login</button>
</form>
私もアプリ/コントローラ/ AUTH-login.jsを持って
import Ember from 'ember';
export default Ember.Controller.extend({
session: Ember.inject.service(),
actions: {
authenticate: function() {
var credentials = this.getProperties('identification', 'password'),
authenticator = 'authenticator:jwt';
this.get('session').authenticate(authenticator, credentials).catch((reason) => {
this.set('errorMessage', reason.error || reason);
});
}
}
});
それだけで動作しますアプリではありませんが、コンポーネントとしてはありません。
テンプレートを空白にして、auth
ルート/アプリを代わりに使用すると、それは桃色になります。
上記の 'components/auth-login.js'が追加されました。「何もアクション 'authenticate'を処理しませんでした。 –
'app/controllers/auth-login.js' - これは' app/components/auth-login.js'で、既存のコードを 'app/controllers/auth-login.js'ファイルから対応するコントローラ – kumkanillam
に移動しますそれは働いて... –