Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have email verification state defined as below, which redirects the state to account if the user is logged in and otherwise it opens up, but the thing is with dynamic params of verification url.

 $stateProvider
.state('verification', {
  url: '/verification/:email/:token',
  templateUrl: 'verification/verification.tpl.html',
  controller: 'VerificationCtrl',
  title: 'Verification',
  resolve: {
    UnauthenticatedUser: ['$q', '$state', 'securityAuthorization', function($q, $state, securityAuthorization){
      var promise = securityAuthorization.requireUnauthenticatedUser()
        .catch(function(){
          // user is authenticated, redirect
          $state.go('account.dashboard');
          return $q.reject();
        });
      return promise;
    }]
  }
});

In this case it should redirect to account.dashboard(/account/dashboard), but it bounce back to this url(/verification/:email/:token) after that.

But if I put the url as /verification only then it works normally the way it is supposed to and redirect to account.dashboard. Can someone suggest where I am going wrong

share|improve this question
    
add your code for the ui router navigation. – Aravind 2 days ago
    
What are you trying to acheive? If the user is unauthenticated you send them to account.dashboard state? Also you have written your $state.go() iside the .catch() loop instead of .then() is that correct? – Bala Abhinav 2 days ago
    
My code is for ui router navigation. If user is unauthenticated it should show the current url, if he is not, that mean he is authenticated(logged in) then requireUnauthenticated User throw error, and then it navigated to his account/dashboard page. – Dark Lord 2 days ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.