Database: revoke role method

master
E. Almqvist 3 years ago
parent 59944b107c
commit ff83c217c8
  1. 6
      src/db_models.rb
  2. 4
      src/lib/database.rb

@ -251,7 +251,11 @@ class User_Role_relation < EntityModel
end end
def self.revoke_role(user_id, role_id) def self.revoke_role(user_id, role_id)
# TODO: revoke role user = User.find_by_id user_id
if user.role_ids.include?(role_id) then
self.delete "role_id = ? AND user_id = ?", role_id, user_id
end
end end
def self.get_user_roles_ids(user_id) def self.get_user_roles_ids(user_id)

@ -86,8 +86,8 @@ class EntityModel
return newid, resp return newid, resp
end end
def self.delete(id) def self.delete(filter="", *args)
self.query "DELETE FROM #{self.name} WHERE id = ?", id self.query "DELETE FROM #{self.name} #{self.apply_filter(filter)}", *args
end end
def self.set(attr, data, filter="") # slower but more lazy def self.set(attr, data, filter="") # slower but more lazy

Loading…
Cancel
Save