title: spring security and angularjs redirecting back to given url after login
body: <p>I have a web application using spring 3.2.The login process is done through spring security.When a user gives a url to view the profile of a particular user he will redirect to login page if he is not logged in.I need to go back to the user's profile if he is not successfully logged in.Since I am using angular js my urls are in the form</p>
  
  <p><a href="http://mydomain.com/#/view-profile/71" rel="nofollow">http://mydomain.com/#/view-profile/71</a> to view the profile of the user.If I am not logged in it will redirect to login page.In the browser url becomes <a href="http://mydomain.com/login#/view-profile/71" rel="nofollow">http://mydomain.com/login#/view-profile/71</a> but after successful login it is not redirecting to the specified url.How can I make that with angularjs.</p>
  
  <p>In app.js I have given like this</p>
  
  <pre><code>$routeProvider.when('/view-profile/:id',
      {
          templateUrl: '/partials/editor/view-profile.htm',
          action: 'kc.view-profile',
          resolve: {
              loadData: ViewCtrl.loadUserProfile
          }
      }
  );
  </code></pre>
  
  <p>And for authentication in security.xml it is written like</p>
  
  <pre><code>    &lt;http use-expressions="true"&gt;
              &lt;!-- Authentication policy --&gt;
              &lt;form-login login-page="/login" login-processing-url="/j_security_check" authentication-failure-url="/login?error=true"/&gt;
              &lt;logout logout-url="/signout" delete-cookies="JSESSIONID" /&gt;
              &lt;intercept-url pattern="/assets/**" access="permitAll" /&gt;
              &lt;intercept-url pattern="/application/signin/**" access="permitAll" /&gt;
              &lt;intercept-url pattern="/application/signup/**" access="permitAll" /&gt;
              &lt;intercept-url pattern="/application/manage/**" access="ROLE_EDITOR" /&gt;
              &lt;interce
  
  pt-url pattern="/application/**" access="isAuthenticated()"  /&gt;
          &lt;!--&lt;intercept-url pattern="/application/connect/**" access="permitAll" /&gt;--&gt;
      &lt;/http&gt;
  
  
      &lt;authentication-manager alias="authenticationManager"&gt;
          &lt;authentication-provider user-service-ref="userDao"&gt;
              &lt;password-encoder ref="passwordEncoder"/&gt;
          &lt;/authentication-provider&gt;
      &lt;/authentication-manager&gt;
  </code></pre>