Copied to clipboard

Flag this post as spam?

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


  • iNETZO 133 posts 496 karma points c-trib
    Jan 29, 2020 @ 20:34
    iNETZO
    0

    Disable "Invite user" option when creating new users

    Hi,

    When a e-mailaddress and a smtp-server is configured in web.config, the "Create user"-button in the users-section is replaced by a dropdown-button and the default option is "Invite user".

    We use Active Directory authentication for our project so we don't want to invite users and let them create their own password.

    enter image description here

    Is it possible to disable the "Invite user" option?

    Best regards,

    iNETZO

  • Ryan Helmn 26 posts 188 karma points
    Feb 10, 2020 @ 14:42
    Ryan Helmn
    0

    Just having a look in the source, currently it's all based on having the mail settings filled out. If it's present it will always show. No override.

    One idea, to get around this, which would require some slight re-structure within your project would be to break the smtp into it's own config with a different name.

    But of course you do lose some core functionality like sending password resets etc.

    This definitely should be a feature request. I think having an app setting labelled something along the lines of 'Umbraco.Core.SendInvites'.

  • Trey 1 post 71 karma points
    Jun 29, 2020 @ 17:28
    Trey
    0

    I was able to get rid of the "Invite User" button by editing the umbraco.controller.js file. In the umbraco.controller.js file, find the following if statement.

            //don't show the invite button if no email is configured
            if (Umbraco.Sys.ServerVariables.umbracoSettings.showUserInvite) {
                vm.defaultButton = {
                    labelKey: 'user_inviteUser',
                    handler: function () {
                        vm.setUsersViewState('inviteUser');
                    }
                };
                vm.subButtons = [{
                    labelKey: 'user_createUser',
                    handler: function () {
                        vm.setUsersViewState('createUser');
                    }
                }];
            } else {
                vm.defaultButton = {
                    labelKey: 'user_createUser',
                    handler: function () {
                        vm.setUsersViewState('createUser');
                    }
                };
            }
    

    And change it to

            //don't show the invite button if no email is configured
            if (false) {
                vm.defaultButton = {
                    labelKey: 'user_inviteUser',
                    handler: function () {
                        vm.setUsersViewState('inviteUser');
                    }
                };
                vm.subButtons = [{
                    labelKey: 'user_createUser',
                    handler: function () {
                        vm.setUsersViewState('createUser');
                    }
                }];
            } else {
                vm.defaultButton = {
                    labelKey: 'user_createUser',
                    handler: function () {
                        vm.setUsersViewState('createUser');
                    }
                };
            }
    

    The above sets the if statement to always be false. Therefore, the "Invite User" button will never be seen...even if you update the default smtp from attribute in the web.config file.

  • iNETZO 133 posts 496 karma points c-trib
    Jun 29, 2020 @ 18:30
    iNETZO
    1

    Thanks Trey, I choose a diffrent method by creating an interceptor, so I didn't had to change the original code.

    angular.module('umbraco.services').config([
        '$httpProvider',
        function ($httpProvider) {
    
            $httpProvider.interceptors.push(function ($q) {
                return {
                    'response': function (response) {
    
                        if (response.config.url.indexOf("views/users/views/users/users.html") === 0) {
                            if (Umbraco.Sys.ServerVariables.umbracoSettings.showUserInvite) {
                                Umbraco.Sys.ServerVariables.umbracoSettings.showUserInvite = false;
                            }
    
                        }
    
                        return response;
                    }
                };
            });
    
        }]);
    
Please Sign in or register to post replies

Write your reply to:

Draft