RafaelVidaurre / angular-permission

Simple route authorization via roles/permissions
MIT License
1.13k stars 212 forks source link

optional query parameters in url #156

Closed Jcbobo closed 8 years ago

Jcbobo commented 8 years ago

I need to have two optional parameter passed by url using the query string, I was able to reach this using ui-router ( plunker ) but is not working in mine application based on angular-permission for handling Authorization.

the state definition where i need this parameter is:

     $stateProvider
             .state('schedule', {
                  url: "/schedule?param1&param2",//&?posizioneList&?areaList&?arbplList
                  views: {
                            'header': {
                                templateUrl: "common/partials/header.tpl.html",
                                controller: "HeaderCtrl"
                              },'content': {
                                 templateUrl: "schedule/partials/schedule.tpl.html",
                                 controller:"ScheduleRecapCtrl"
                          }
                  },
                   resolve:{
                         Filters:'Filters',
                              availableFilters:function(Filters){
                                      return Filters.get().$promise;
                          }
                   }, data: {
                             permissions: {
                                  only: ['logged'],
                                  redirectTo: 'login'
                              }
                    }
                  })

this is mine groups definition

app..run(function (PermissionStore, authenticationSvc) {
        // Define anonymous permission
        PermissionStore
            .definePermission('anonymous', function (stateParams) {
                // If the returned value is *truthy* then the user has the permission, otherwise they don't
                return !authenticationSvc.isLogged();
            });
        PermissionStore.definePermission('logged', function (stateParams) {
                return authenticationSvc.isLogged();
            });

I noted that after reaching the state with the parameters a new $stateChangeStart is triggered (before the $stateChangeSuccess) but without the parameters that comes from the url.

this is the dependencies section of my bower.json file

"dependencies": {
    "angular": "~1.4.0",
    "angular-bootstrap": "~1.1.2",
    "angular-loader": "~1.4.0",
    "angular-mocks": "~1.4.0",
    "angular-route": "~1.4.0",
    "angular-ui-router": "~0.2.17",
    "html5-boilerplate": "~5.2.0",
    "angular-animate": "^1.4.9",
    "angular-permission": "^2.0.1",
    "bootstrap": "^3.3.6",
    "startbootstrap-sb-admin-2": "^1.0.8",
    "angular-filter": "^0.5.8",
    "angular-block-ui": "^0.2.2",
    "angular-resource": "^1.5.0",
    "angular-local-storage": "^0.2.3",
    "angular-toastr": "^1.7.0",
    "angular-translate": "^2.9.1",
    "angular-sanitize": "^1.5.0",
    "angular-translate-storage-local": "^2.9.1",
    "angular-cookies": "^1.5.0",
    "angular-translate-loader-static-files": "^2.9.1"
  },```
masterspambot commented 8 years ago

Can you update angular-permission to 2.0.9/2.1.0-beta and check if problem still appears?

Jcbobo commented 8 years ago

with the 2.0.9 version the problems is still present, as soon I can I will try with the 2.1.0-beta version

edit: based on my build/deploy script i can not check with the beta version (sorry) adding a resolve to the state lead to the same issue

masterspambot commented 8 years ago

I reproduced the case and everything seems to be fine: http://plnkr.co/edit/bXjmzxvN3JQ33fjRquBt?p=preview