mail icon indicating copy to clipboard operation
mail copied to clipboard

Disable adding of own accounts

Open kroerig opened this issue 2 years ago • 1 comments

Feature Request

From https://help.nextcloud.com/t/disable-setting-add-new-mail-account/106160

Users can add their own accounts. It should be possible to disable this function globally.

Summary

Adding external accounts could break data protecion rules.

kroerig avatar Nov 30 '21 14:11 kroerig

I really needed this functionality so i performed this hack in my config.php:

$user = !empty($_COOKIE['nc_username']) ? $_COOKIE['nc_username'] : '';
if (empty($user) && !empty($_SERVER['PHP_AUTH_USER']) ) {
  $user = $_SERVER['PHP_AUTH_USER'];
}
else if (empty($user) && !empty($_SERVER['REQUEST_URI']) && preg_match('/\/(dav\/files|users?)\/([^\/]+)/',$_SERVER['REQUEST_URI'],$matches) ) {
  $user = $matches[2];
}
else if (empty($user) && strpos($_SERVER['PHP_SELF'],'/cron.php') > 0 ) {
  $user = '> CRON call <';
}
if ( !empty($user) && $user != '> CRON call <'
############### exclude your users here that do get access #
 && ($user != 'admin_user' && $user != 'another_admin_user')
############################################################
 && strpos($_SERVER['PHP_SELF'],'/mail/') > 0 # or put 'mail/setup' here if you want to disable the ability to create/add a mail account
) {
 die('you have no access to this part of the site'); 
}

mrAceT avatar Jul 06 '22 12:07 mrAceT