• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Dashboard login based on user's permissions.

    Dashboard Designer & Custom AngularJS Pages
    3
    7
    2.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      Tomi
      last edited by Tomi

      I would like to set user's permissions in custom dashboards (the same used at datapoints/datasources). So if user's permissions doesn't match dashboard permissions it will redirect to login page. I believe it should be a directive, but I don't know how to implement it.

      1 Reply Last reply Reply Quote 0
      • Jared WiltshireJ
        Jared Wiltshire
        last edited by

        Hey tomi, I can help you with this. What template did you start with?

        Developer at Radix IoT

        1 Reply Last reply Reply Quote 0
        • T
          Tomi
          last edited by

          Hello Jared, thank you. I am using Admin Template.

          1 Reply Last reply Reply Quote 0
          • Jared WiltshireJ
            Jared Wiltshire
            last edited by

            Make these changes in app.js

            Around line 40:

                        auth: ['$rootScope', 'User', function($rootScope, User) {
                            // retrieves the current user when we navigate to a dashboard page
                            // if an error occurs the $stateChangeError listener redirects to the login page
                            $rootScope.user = User.current();
                            return $rootScope.user.$promise.then(function(user) {
                                if (!user.hasPermission('my-permission')) {
                                    throw 'Wrong permission';
                                }
                                return user;
                            });
                        }],
            

            Around line 221

                // redirect to login page if we can't retrieve the current user when changing state
                $rootScope.$on("$stateChangeError", function(event, toState, toParams, fromState, fromParams, error) {
                    if (error && (error.status === 401 || error.status === 403 || error === 'Wrong permission')) {
                        event.preventDefault();
                        $state.loginRedirect = toState;
                        $state.go('login');
                    }
                });
            

            Developer at Radix IoT

            1 Reply Last reply Reply Quote 0
            • T
              Tomi
              last edited by

              Thank you Jared, it works smoothly.

              Also, I would like to redirect to the dashboard login page after user click on logout button. Currently it goes to the default Mango login page.

              1 Reply Last reply Reply Quote 0
              • JoelHaggarJ
                JoelHaggar
                last edited by

                You should be able to control that from the system setting. Here is a screenshot of mine. Setting the Login page url should do this for you.

                0_1467139515373_upload-2a761e09-f89d-46a9-9696-41f51db9405d

                T 1 Reply Last reply Reply Quote 0
                • T
                  Tomi @JoelHaggar
                  last edited by

                  @JoelHaggar Thanks Joel, I did that, but I have 2 different dashboards, so I would like to go to the login page of the dashboard which I am leaving.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post