summaryrefslogtreecommitdiffstats
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-04-15 14:31:54 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-04-15 14:31:54 +0000
commit28f0c4f131b02ab67bd9c254f9853168ec6a5b65 (patch)
treefeedcef78913a173d5f8776c3f13e0f8990c317b /app/models/user.rb
parent638583012ae165e5cb197fb3b4d7a0fe54318217 (diff)
downloadredmine-28f0c4f131b02ab67bd9c254f9853168ec6a5b65.tar.gz
redmine-28f0c4f131b02ab67bd9c254f9853168ec6a5b65.zip
Adds the ability for users to delete their own account (#10664). Can be disabled in application settings.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9417 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index d1fa2822a..b377dda67 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -482,6 +482,12 @@ class User < Principal
allowed_to?(action, nil, options.reverse_merge(:global => true), &block)
end
+ # Returns true if the user is allowed to delete his own account
+ def own_account_deletable?
+ Setting.unsubscribe? &&
+ (!admin? || User.active.first(:conditions => ["admin = ? AND id <> ?", true, id]).present?)
+ end
+
safe_attributes 'login',
'firstname',
'lastname',