jeudi 19 mars 2015

How to detect if the user have come from external link?

Is there a way to distinguish access through external link (e.g. from history, or from other site) or access by link from other page of the same app in beforeModel handler?


Here is my case:



  1. If user accesses my app by direct link and requests route requiring authenticated user, I make a transition to index route and show popup with an authorization form.

  2. If user is already on my site and trying to access the requested route requiring authenticated user, I abort transition and show the popup on a previous page.

  3. I have no separate page for authentication.


My current work around is to check some strange private property called sequence of transition object which has been passed to beforeModel handler, if transition.sequence === 0, then user came from "outside", otherwise user follow by link "inside" my app.


I think this is a bad way to achieve the goal, core developers can remove sequence property any time.


So, is there any clean way to distinguish whether current route was requested from "outside" or "inside" of my app?


I'll appreciate any help, thanks!


P.S. EmberJS v1.10.0


P.S.S. Sorry for my English





Aucun commentaire:

Enregistrer un commentaire