Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Zihadul Azam 26 posts 170 karma points c-trib
    Sep 25, 2017 @ 09:55
    Zihadul Azam
    0

    Hide users of other groups

    Currently, I'm building a collection of websites similar to this one:

    enter image description here

    Now I want to create an admin for each site and give him the permission to manage his site users (create an editor, delete editor...). But I noticed that, if I give him the User Section permission he can see also the other sites users (other groups).

    In short words: I would like to have: every site has a group of users, there is an Admin who can manage them and he can't see (edit) other sites users

    Is there any solution?

    Umbraco Version: 7.7.1

    -Thanks

  • Alex Skrypnyk 5241 posts 19098 karma points MVP 3x admin c-trib
    Sep 25, 2017 @ 20:32
    Alex Skrypnyk
    1

    Hi Zihadul

    The easiest way to use Umbraco instance per site, can you just copy your Umbraco for each website? Why do you need to store everything in one Umbraco?

    Thanks,

    Alex

  • Zihadul Azam 26 posts 170 karma points c-trib
    Sep 26, 2017 @ 07:40
    Zihadul Azam
    0

    Hii Alex,

    Yes, I've to run all websites (150-200 websites) in one single Umbraco installation, because they have relations between them (Ex: Sharing Content).

    Everything is excellent in Umbraco, only the Hierarchical User Management is missing. It would be fantastic if the next Umbraco version includes this function, because I read a lot of comments where the developers are demanding.

    Thanks

  • Zihadul Azam 26 posts 170 karma points c-trib
    Oct 11, 2017 @ 09:19
    Zihadul Azam
    102

    I solved this problem using angularJs Interceptor. I intercept the result of the Umbraco Core user controller, then filter users.

    angular.module('umbraco.services').config(function ($httpProvider) {
    
        $httpProvider.interceptors.push(function ($q, $injector) {
            return {
                'request': function (request) {
                    if (request.url.includes("umbraco/backoffice/UmbracoApi/Users/GetPagedUsers")) {
                        // set page Size 1025 (to get all users & filter them), by default umbraco request only 25 users
                        var splittedUrl = request.url.split("pageSize=");
                        var newUrl = splittedUrl[0] + "pageSize=100" + splittedUrl[1];
                        request.url = newUrl;
                    }
                    return request;
                },
                'response': function (response) {
    
                    // intercept GetPagedUsers response data
                    if (response.config.url.includes("umbraco/backoffice/UmbracoApi/Users/GetPagedUsers")) {
    
                        //get users
                        var users = response.data.items;
    
                        if (users.length > 0) {
                            // umbraco userService
                            var userS = $injector.get('userService');
    
                            // get Current User
                            return userS.getCurrentUser()
                                .then(function (currentUser)
                                {
                                    if (currentUser !== null) {
                                        // if the current user is not super admin (can see all users), then filter
                                        if (!isSuperAdmin(currentUser.userGroups)) {
                                            // get $http
                                            var http = $injector.get('$http');
    
                                            // get page number
                                            var pageNumber = getPageNumber(response.config.url);
                                            // set page size
                                            var pageSize = 25;
    
                                            // set send data for custom filter controller
                                            var sendedData = { users: JSON.stringify(users), pageNumber: pageNumber, pageSize: pageSize };
    
                                            // call custom UmbracoAuthorized Filter controller
                                            return http.post("backoffice/UserInterceptorPlugin/MyUsersController/Filter", angular.toJson(sendedData))
                                                .then(function (res)
                                                {
                                                    // parse to Json Object
                                                    res = JSON.parse(JSON.parse(res.data));
    
                                                    // set response data to return 
                                                    response.data.items = res.resUsers;
                                                    response.data.totalItems = res.resUsers.length;
                                                    response.data.pageSize = pageSize;
                                                    response.data.userStates.All = res.resUsers.length;
                                                    response.data.userStates.Active = res.activeUsers;
                                                    response.data.userStates.Disabled = res.disabledUsers;
                                                    response.data.userStates.Invited = res.invitedUsers;
    
    
                                                    return response;
                                                });
                                        }
                                    }
                                    return response;
                                });
                        }
                    }
                    return response;
                }
            };
        });
    
        // check if has admin group
        var isSuperAdmin = function (userGroups) {
            var res = false;
            angular.forEach(userGroups, function (group, index) {
                if (group === "admin")
                    res = true;
            });
    
            return res;
        }
    
        // get pageNumber param form URL 
        var getPageNumber = function (url) {
            var split = url.split("pageNumber=");
            var number = split[1].split("&");
            return number[0];
        }
    
    });
    
Please Sign in or register to post replies

Write your reply to:

Draft