official_module/app/controllers/admin/official_module_controller.rb

36 lines
1.0 KiB
Ruby
Raw Normal View History

2021-07-15 09:08:06 +00:00
class Admin::OfficialModuleController < OrbitAdminController
2021-07-15 10:59:12 +00:00
layout "structure"
2021-07-15 09:08:06 +00:00
def set_master_key
@master_password = MasterPassword.first rescue nil
if @master_password.nil?
@master_password = MasterPassword.new
end
end
def update_master_password
master_password = MasterPassword.first rescue nil
if master_password.nil?
master_password = MasterPassword.create(password_params)
else
master_password.update_attributes(password_params)
master_password.save
end
# emails = User.all.collect{|u| u.member_profile.email rescue nil}
# emails.delete(nil)
# Email.new({
# "mail_to" => emails,
# "mail_subject" => "Master password changed.",
# "mail_content" => "Master password has been changed for all the sites. Please login with the new password. The new password is : <h3>#{password_params[:password]}</h3>"
# }).deliver
redirect_to admin_site_set_master_key_path(current_site)
end
private
def password_params
params.require(:master_password).permit!
end
end