ember.js - ensure user login in Ember app -
Is the user the best way to ensure that the user is logged into the Amber App?
I would like to stop any url before getting excited about routing, will show a model popup with user_id / password, and go to the original url.
Perhaps something like Rail Application - the first_filter to be executed before any other controlling methods.
I have the following routing:
App.Router.map (function () {this.resource ('folder', {path: '/'}, function () {This.resource ('files', {path: '/: folder_id'}, function () {this.route ('index');})}};}); I'm trying to set up ApplicationRoute:
App.ApplicationRoute = Ember.Route.extend ({activate: function () {console.log ("Enable App Routes" );}}); But the problem is, if I hit index.html # / folder01 , folder is executed before application route summarizing workflow Appearance should appear:
- User hit
index.html # / folder01 url - App check is not a user login. If no modal popup
- After login, the app must
index.html # / folder01 URL thanks a lot!
It seems that I found a solution that works. Here it is:
App.Router.reopen ({startRouting: function () {if (! App.userProfile.get ('Login')) {$ ("# login_dialog") Modal ('Show'). A ('click', "# login_btn", function () {$ ("# login_dialog"). Modal ('hide'); App.userProfile.set ('loggedIn' is true) ; App. Start ();});} other {this._super ();}}}); If the app detects a session timeout, then it executes window.location.reload () . app.reset () would be good to work, but it has not yet been implemented correctly. I'm not 100% sure that in this solution memory leaks or stuff like this I would love to hear anything from Amber experts about this approach.
Thanks
Comments
Post a Comment