dimanche 11 janvier 2015

Ember: Applications with user login

How should I construct the Router for an Application with customer login?


The application requires login to access the following routes: Books, Book, Chapters, ChapterCategory, Chapter.


The routes About and Home not require the user to be logged.



App.Router.map(function() {
this.resource('application', function() {
this.resource('home');
this.resource('books');
this.resource('book', {path: '/:book_id'});
this.resource('chapters');
this.resource('chapterCategory', {path: 'chapter/:chapter_type'});
this.resource('chapter', {path: '/:chapter_id'});
this.resource('about', {path: '/aboutus' });
});
this.route('catchall', {path: '/*wildcard'});
});


When the user is logged, his name is added to the right of the main menu which is implemented in the Application template. Hence, the Application route is extracting the user information. If the user is not logged, the application model does not return anything.


Questions:




  1. It there any special considerations to be aware of when defining a model in the Application route?




  2. How could the application template, where the customer name is displayed in the navigation menu be updated if the application route does not try to extract the user information?




  3. How do you implement user login in you own Ember applications? Do you create a User route and nest the routes requiring login under it?




Thanks


Aucun commentaire:

Enregistrer un commentaire