angularjs - Redirect after login to backbone route with rails -


I am trying to provide users with a general functionality, to log in to the original requesting URL Afterwards, I'm redirecting them to a safe path. For example, the user clicks the link on the email through the notification in the system, tries to go on it: the user is not logged in, so is brought back after the entry, they should not be brought to their home page, rather the original form For the requested URL from

I am very popular with the technique to save the effort URL in the session before redirecting to the login page. The point is that the URL has a backbone router after the core URL, i.e.

the #details part of the URL is not sent to the server as it is usually for internal page jump. I am thinking that how are the web developers working like JS MVC framework like spine, angular and others are emerging? Some moves? Is there really any way to pass the server in the HTTP specification?

Any idea is appreciated, thanks.

The easiest solution to this problem, if you do not need to support this behavior for older browsers , Then PushState has to be enabled in your spine router so that you get to # routes:

backbone. History.state ({pushState: true}); Edit:

Other possible solutions, though it's a bit confusing, to find out what should be after the hash and navigate that path. For example, suppose you want to navigate:

http://webapp.com/abc/ # page 1 where 'page 1' is the segment that backbone root makes.

If you use the http://webapp.com/abc/page1 You can find out if the browser is PushState or not. If not, you can change everywhere after 'Route'. Here are some example codes that can take you on the right track to support both sets of browsers:

  var _defaults = {pushstate: Modernizr.history, silent: true, root : '/'}; Var start = function (options) {// start routing with pushstate or without option = _.extend (_ clone (this._defaults), option); Backbone.history.start (options); If (options.pushState) {Backbone.history.loadUrl (backbone.istory.getFragment ()); Return; } This.degradeToNonHistoryURL (); }; / ** * For the slice URL, we check that the actual request is for root or '/', if it is, then we can continue and will backbone magic * if we do not redirect with root one Route as piece * foo.com/bar/1 - & gt; Foo.com/#bar/1 * / degradeToNonHistoryURL = function () {var pathName = window.location.pathname; // If the root is '/', the length is one. If the root is 'foo', then length 5 (/ foo /) var is root lang = _getRoot (). Length; Var isRootRequest = pathName.length === Root Lamp; If (! IsRootRequest) {var path = pathName.substr (rootLength); Window.location.href = _getRoot () + '#' + Route + window.location.search; Return; Backbone.history.loadUrl (backbone.istory.getFragment ()); }, / ** * Get the effective route of the app normally it is '/', but if set to 'foo', we want to return '/ foo /' so that we can easily determine it Whether or not this is a root request * @ Layers {string} Effective Root * / _getRoot = function () {if (Backbone.history.options.root === '/') {Return '/'; } Return '/' + backbone. History. Option .rot + '/'; },  

The trick here is making your unique URL to the pushstate URL and is always sending the users to those people to adopt the browser. After growing, without breaking all your links, all these nonsense should be theoretically easy to bite.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -