saucy/app/models/user.rb

28 lines
688 B
Ruby
Raw Normal View History

2022-06-25 22:45:47 +00:00
class User < ApplicationRecord
include Clearance::User
def self.update_board_members(new_emails)
where(active: true).each do |user|
if !new_emails.include?(user.email)
user.update(active: false)
# TODO: notify board member of deactivation
end
end
new_emails.each do |email|
user = User.find_by(email: email)
if user
if !user.active?
# TODO: notify board member of activation
user.update(active: true, password: SecureRandom.hex(32))
end
else
# TODO: notify board member of activation
User.create(email: email, password: SecureRandom.hex(32))
end
end
end
end