Code Monkey home page Code Monkey logo

Comments (8)

yhonguevara avatar yhonguevara commented on June 26, 2024 1

@amrinder23 If you use !, the only thing different is the statement app.run ()

app.run(['$rootScope', '$state', function ($rootScope, $state) {
  // If the route change failed due to our "Unauthorized" error, redirect them
  $rootScope.$on('$stateChangeError', function (event, toState, toParams, fromState, fromParams, rejection) {
    if (rejection === 'Unauthorized') {
      $state.go('home');
    }
  });
}]);

from angular-acl.

mikemclin avatar mikemclin commented on June 26, 2024

@amrinder23 I m not as familiar with UI Router. I can figure it out and post here eventually (I'm getting ready to leave for work). In the meantime, I'd suggest searching "angular ui router protect routes" or something similar to see the mechanism for bailing out of a route based on some sort of logic. Then I'd implement this angular-acl package into that flow.

If you find a good solution, please share 😄

from angular-acl.

mikemclin avatar mikemclin commented on June 26, 2024

@yhon92 thanks for the comment 👍

from angular-acl.

amrinder23 avatar amrinder23 commented on June 26, 2024

Thanks @yhon92 .. I will try this. 👍

from angular-acl.

amrinder23 avatar amrinder23 commented on June 26, 2024

Thanks @mikemclin for an awesome service.
Thanks @yhon92 it worked for me. $state didnt work in app.run method. I had to get its instance using $injector.get("$state"). Then it worked for me.

from angular-acl.

amrinder23 avatar amrinder23 commented on June 26, 2024

@mikemclin .. Just another question.
After implementing angular-acl in my application, when i refresh the browser it considers it as $stateChangeError and it goes into that code block (rejection==='Unauthorized') and sets the current state to the one set there.

Can't we remain on the same state ?

from angular-acl.

yhonguevara avatar yhonguevara commented on June 26, 2024

@amrinder23

  1. what version you're using ui-router?

  2. I use $stateChangeStart to capture the event to load the browser, and if the key there AclService in the localStorage use the function AclService.resume(); to continue operation.

from angular-acl.

amrinder23 avatar amrinder23 commented on June 26, 2024

@yhon92 I am using v0.2.15 of ui-router

from angular-acl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.