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

Hide title depending on the result of the localStorage #423

Open
danielswater opened this issue May 2, 2019 · 0 comments
Open

Hide title depending on the result of the localStorage #423

danielswater opened this issue May 2, 2019 · 0 comments

Comments

@danielswater
Copy link

After the user logs in to the system, I store his data in a localStorage, within a service. Based on this, I need to set up a menu with the permissions of each user. Each menu item is in a BlurAdmin module. I can recover the data, however I can not hide the link, if the user does not have the permission. Here is the code:

`(function() {
'use strict';

angular.module('BlurAdmin.pages.dashboard', [])
    .config(routeConfig);

/** @ngInject */
function routeConfig($stateProvider) {

    $stateProvider
        .state('dashboard', {
            resolve: {
                user: function(baSidebarService, $q){
                    var user = JSON.parse(baSidebarService.getStorage());
                    console.log(user)
                      var roles = ["GERENTE","ADMIN"];
                    user.roles.forEach(function(role){
                        if(roles.includes(role.nome)){
                            console.log('ok')
                        }
                        else{
                            return;
                        }
                    })                        
                }
            },
            // if baSidebarService.getStorage() == true
            url: '/dashboard',
            templateUrl: 'app/pages/dashboard/dashboard.html',
            title: "Dashboard",                
            sidebarMeta: {
                icon: 'ion-android-home',
                order: 0,
            },
        });
}

})(); `

Note that within the loop, I make a check if the user data is the same as the rules. The problem is that even though I check that they are different, I can not hide the Dashboard link. I already tried everything, with no success.

How could I do this, for example, depending on localStorage data:

// if baSidebarService.getStorage() == true url: $scope.dashboard, templateUrl: $scope.template, title: $scope.title, sidebarMeta: $scope.sidebar,

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

1 participant