protected;
- def user_exists(account)
- ad_users = list_users()
- return ad_users.include?(account)
- end
def list_users()
usernames = []
raise NotImplementedError
end
+ def user_exists(username)
+ # Does the given username exist for this plugin? We use a naive
+ # implementation here based on list_users() which is required to
+ # exist above. Plugins can override this with something fast.
+ users = list_users()
+ return users.include?(username)
+ end
+
def list_domains_users(domains)
# Get all usernames belonging to the given domains. If a username
# ends in @example.com, it belongs to the domain example.com
def delete_account(account)
# Delete the given username and any records in other tables
# belonging to it.
+ raise NonexistentAccountError.new(account) if not user_exists(account)
sql_queries = ['DELETE FROM prefs WHERE username = $1;']
sql_queries << 'DELETE FROM shared WHERE user_from = $1;'
# Delete the given username. DAViCal uses foreign keys properly
# and only supports postgres, so we let the ON DELETE CASCADE
# trigger handle most of the work.
+ raise NonexistentAccountError.new(account) if not user_exists(account)
+
sql_queries = ['DELETE FROM usr WHERE username = $1']
begin
def delete_domain(domain)
+ # Will raise an exception if the path doesn't exist.
domain_path = self.get_domain_path(domain)
FileUtils.rm_r(domain_path)
end
def delete_account(account)
+ # Will raise an exception if the path doesn't exist.
account_path = self.get_account_path(account)
FileUtils.rm_r(account_path)
end
def delete_account(account)
+ raise NonexistentAccountError.new(account) if not user_exists(account)
+
sql_queries = ['DELETE FROM alias WHERE address = $1;']
# Wipe out any aliases pointed at our account.
sql_queries << "UPDATE alias SET goto=REPLACE(goto, $1, '');"
def delete_account(account)
# Delete the given username and any records in other tables
# belonging to it.
+ raise NonexistentAccountError.new(account) if not user_exists(account)
+
user_id = self.get_user_id(account)
# The Roundcube developers were nice enough to include