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

add removeState() to $stateProvider [feature] #1095 #1114

Closed
wants to merge 1 commit into from
Closed

add removeState() to $stateProvider [feature] #1095 #1114

wants to merge 1 commit into from

Conversation

ilyagelman
Copy link

@eddiemonge
Copy link
Contributor

Can you give use cases for this?

@paulflo150
Copy link

I would like to see this implemented as well, as it would be very useful for states that are being added via a provider upon a user's login.

@eddiemonge, here is the way my app works:

  1. I have a couple of default states a user can access without having to login which I hard coded in the config phase.
  2. Upon a successful login, and based on the user's roles I retrieve the states this particular user has access to, and add them via a provider.
  3. So far all is well, but when the user logs out, and if another user logs in without performing a hard refresh, one cannot clear out/ override any of the previous states.

Is there perhaps a way to remove ALL the routes that I may have missed in the docs?

Assuming there isn't, what are the chances we will be seeing a removeState anytime soon?

Thanks!

@eddiemonge
Copy link
Contributor

Why not use the state's data option and specify what role is needed to access the state. in the stateChangeStart event, check if the user has that role and if not then you take them to an error page? Then you don't need to muck about with adding/removing states.

Closing this because it needs a lot of work.

  • The release files were edited instead of src
  • Its missing tests
  • The commit message doesn't follow the contributing guidelines

@eddiemonge eddiemonge closed this Aug 14, 2015
@paulflo150
Copy link

One could do that, but having to maintain roles in two places, and hard code them in the UI layer seems like a poor design.

@RichardFans
Copy link

we need this feature ! eddiemonge, please give us removeState()

@vinothbabu
Copy link

@paulflo150 : This would be rarely used, i am just thinking the scenarios... if a user removes a state via removeState(), it would be there only until the application lifecycle, once its app is reloaded, your state is still accessible. There should be somebackend mechanism needed for persistance.

Why not use resolve

.state('someState', { url: url, templateUrl: template, controller: 'Ctrl' resolve: { permission: function (Factory, $window) { return Factory.checkPermission($window.sessionStorage.sendSomething); } } })

Inside your checkPermission method, you can see whether he can access or not... based on that you can redirect him to other state. I am not against adding this method, just thought would throw in some my thoughts.

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

Successfully merging this pull request may close these issues.

5 participants