Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State params not passed to signin state #451

Open
dragos-cojocari opened this issue May 16, 2019 · 2 comments
Open

State params not passed to signin state #451

dragos-cojocari opened this issue May 16, 2019 · 2 comments

Comments

@dragos-cojocari
Copy link

Environment:

  • Angular 1.5.8
  • angular-permissions: 4.1.2

Behavior:

  • params are not preserved , the signin state and the transitionProperties have no data from previous states. So navigation from /web/1234 goes to /web/signin instead of /web/signin/1234

Issue:
Is state params transfer supported? Do I have a configuration error?

main.module.js

function routeConfig($stateProvider) {
  $stateProvider
    .state('main', {
      url: '/:tenantid/',
      replace: "false",
      templateUrl: 'pages/main.html',
      redirectTo: 'main.dashboard',
      data: {
        access: ['AUTHORIZED', 'ADMIN'],
        permissions: {
          only: ['AUTHORIZED'],
          redirectTo: function(rejectedPermission, transitionProperties) {
            return {
              state: 'signin',
              options: {
                reload: true
              }
            };
          }
        }
      }
    });

login.module.js

function routeConfig($stateProvider) {
  $stateProvider
    .state('signin', {
      url: '/signin/:tenantid',
      templateUrl: 'pages/login/signin.html'
    });
}

The transitionProperties shows the following:

{
  "toState": {
    "url": "/signin/:tenantid",
    "templateUrl": "pages/login/signin.html",
    "name": "signin",
    "$$isAuthorizationFinished": false
  },
  "toParams": {
    "tenantid": ""
  },
  "fromState": {
    "name": "",
    "url": "^",
    "views": null,
    "abstract": true
  },
  "fromParams": {},
  "options": {
    "location": true,
    "inherit": true,
    "relative": {
      "self": {
        "name": "",
        "url": "^",
        "views": null,
        "abstract": true
      },
      "resolve": {},
      "url": {
        "segments": [
          ""
        ],
        "params": {},
        "source": "",
        "sourcePath": "",
        "sourceSearch": "",
        "regexp": {},
        "prefix": "",
        "$$paramNames": []
      },
      "navigable": null,
      "ownParams": {},
      "params": {},
      "views": {},
      "path": [],
      "includes": {
        "": true
      },
      "locals": {
        "resolve": null,
        "globals": {
          "$stateParams": {}
        }
      }
    },
    "notify": true,
    "reload": true,
    "$retry": false
  }
}```

Thank you.
@masterspambot
Copy link
Collaborator

I think that solution to your problem is explained here:
https://github.com/RafaelVidaurre/angular-permission/wiki/Usage-in-ui-router-states#single-redirection-rule
https://github.com/RafaelVidaurre/angular-permission/wiki/Usage-in-ui-router-states#dynamic-redirection-rules

See that params has to be passed to redirection function in order to be handled properly by router.

@dragos-cojocari
Copy link
Author

dragos-cojocari commented May 30, 2019

Thanks @masterspambot masterspambot

See that params has to be passed to redirection function in order to be handled properly by router.
Right, I saw that but my problem is that no params or state params or transitionProperties are available in the redirectTo function. The param is not static, it comes from the stateParams of the previous state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants