Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect to the page containing # (hash) sign after login

I am using Spring Security and wondering how can I implement redirection after succesfull login to the source page if that page contains # (hash) sign.

Right now I use always-use-default-target="false" and it works fine on URL kind of: /path/to/page/.

But when the URL become to #/path/to/page it doesn't make any redirections.

Is there any way to fix it?

like image 337
nKognito Avatar asked Oct 04 '12 08:10

nKognito


1 Answers

Here is the solution I used at the end:

$(document).ready(function(){
  $('#auth-form').submit(function() {
    var el = $(this);
    var hash = window.location.hash;
    if (hash) el.prop('action', el.prop('action') + '#' + unescape(hash.substring(1)));
    return true;
  });
});

This snippet addes the hash to authorization form's action attribute and Spring redirect you to the URL of kind: #/path/to/page without any problem.

like image 73
nKognito Avatar answered Sep 19 '22 19:09

nKognito