Best way to enforce user/authentication state in Ember.JS app

后端 未结 4 1728
后悔当初
后悔当初 2021-01-31 02:42

Working on my first EmberJS app. The entire app requires that a user be logged in. I\'m trying to wrap my head around the best way to enforce that a user is logged in now (when

4条回答
  •  闹比i
    闹比i (楼主)
    2021-01-31 03:24

    If you need to perform a check before initial state transition, there is a special function on the Ember.Application class called deferReadiness(). The comment from the source code:

    By default, the router will begin trying to translate the current URL into application state once the browser emits the DOMContentReady event. If you need to defer routing, you can call the application's deferReadiness() method. Once routing can begin, call the advanceReadiness() method.

    Note that at the time of writing this function is available only in ember-latest

提交回复
热议问题