私はEmberの初心者であり、学習の一環として、あるチュートリアルからログインフォームを設定しようとしていましたが、機能していないようです。 エラー:無効なパス---ログインメソッドで取得しているエラーです
パスワードに問題がないかどうかを確認してから、ログインテンプレートに接続します。それ以外の場合は、ユーザーを「/」にキックします。
HTMLファイル
<script type="text/x-handlebars" data-template-name="login">
{{message}} <br>
E-Mail {{view Ember.TextField target="controller" valueBinding= controller.email}} <br />
Password {{view Ember.TextField target="controller" valueBinding= controller.password}} <br />
<button {{action login}}>Login</button>
</script>
<script type="text/x-handlebars" data-template-name="loggedin">
Welcome to Our Site !
</script>
JSファイル
App.LoginController = Ember.ObjectController.extend({
email :null,
password :null,
message :null,
login : function() {
var loginCreds = this.getProperties('email','password');
if (loginCreds.password === 'admin') {
this.set('isAuthenticated',true);
console.log(isAuthenticated);
this.get('target').send('isAuthenticated');
}
else{
this.set('message','Invalid password');
this.set('isAuthenticated',false);
console.log(isAuthenticated);
this.get('target').send('isAuthenticated');
}
}
});
App.LoginRoute = Ember.Route.extend({
isAuthenticated : function(router) {
router.transitionTo('loggedin');
},
connectOutlets: function(router) {
if (!router.get('loginController.isAuthenticated')) {
router.transitionTo('/');
}
router.get('loginController').connectOutlet('loggedin');
},
});