このチュートリアルで簡単な認証を作成しました。
http://www.embercasts.com/episodes/client-side-authentication-part-1
したがって、AuthenticatedRoute を作成しました。ログインしているユーザーが必要な他のすべてのルートは、AuthenticatedRoute を拡張しています。
beforeModel では、ユーザーがログインしているかどうかを確認します。ログインしていない場合は、次のように呼び出しますthis.transitionTo("login")
。
私の質問は次のとおりです。ログインフォーム全体をパネルに配置するにはどうすればよいですか? 私の考えは、AuthenticatedRoute -> beforeModel イベントでパネルを開き、ログインが成功した場合は、リダイレクトを再試行することでした。
私のアイデアですが、それを実装する方法がわかりません。
App.AuthenticatedRoute = Ember.Route.extend({
beforeModel: function(transition) {
if (!App.get("currentUser")) {
transition.abort(); // loading spinner doesn't disappears if i call this??
this.showLogin(transition);
}
},
showLogin: function(transition) {
var loginController = this.controllerFor("login");
loginController.set("attemptedTransition", transition);
// OPEN PANEL, if the panel gets closed, do nothing. If login successfull, redirect to attemptedTransition and hide the panel.
}
});