mirror of
https://github.com/internetee/registry.git
synced 2025-07-27 13:06:18 +02:00
Added committed param to white ip
This commit is contained in:
parent
e00e44c9b8
commit
1c8a46bd89
12 changed files with 130 additions and 15 deletions
|
@ -41,7 +41,7 @@ module Admin
|
|||
def sign
|
||||
if @certificate.sign!(password: certificate_params[:password])
|
||||
flash[:notice] = I18n.t('record_updated')
|
||||
notify_api_user
|
||||
notify_registrar
|
||||
redirect_to [:admin, @api_user, @certificate]
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_update_record')
|
||||
|
@ -88,10 +88,10 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def notify_api_user
|
||||
api_user_email = @api_user.registrar.email
|
||||
def notify_registrar
|
||||
email = @api_user.registrar.email
|
||||
|
||||
CertificateMailer.signed(email: api_user_email, api_user: @api_user,
|
||||
CertificateMailer.signed(email: email, api_user: @api_user,
|
||||
crt: OpenSSL::X509::Certificate.new(@certificate.crt))
|
||||
.deliver_now
|
||||
end
|
||||
|
|
|
@ -36,7 +36,11 @@ module Admin
|
|||
end
|
||||
|
||||
def update
|
||||
previously_committed = @white_ip.committed
|
||||
|
||||
if @white_ip.update(white_ip_params)
|
||||
notify_registrar if !previously_committed && @white_ip.committed
|
||||
|
||||
flash[:notice] = I18n.t('record_updated')
|
||||
redirect_to [:admin, @registrar, @white_ip]
|
||||
else
|
||||
|
@ -52,7 +56,14 @@ module Admin
|
|||
end
|
||||
|
||||
def white_ip_params
|
||||
params.require(:white_ip).permit(:ipv4, :ipv6, :registrar_id, { interfaces: [] })
|
||||
params.require(:white_ip).permit(:ipv4, :ipv6, :registrar_id, :committed, { interfaces: [] })
|
||||
end
|
||||
|
||||
def notify_registrar
|
||||
email = @white_ip.registrar.email
|
||||
|
||||
WhiteIpMailer.committed(email: email, ip: @white_ip)
|
||||
.deliver_now
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -174,7 +174,7 @@ module Repp
|
|||
end
|
||||
|
||||
def serialized_ips(ips)
|
||||
ips.as_json(only: %i[id ipv4 ipv6 interfaces])
|
||||
ips.as_json(only: %i[id ipv4 ipv6 interfaces committed])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,21 +31,21 @@ module Repp
|
|||
return
|
||||
end
|
||||
|
||||
notify_admins if @white_ip.interfaces.include? WhiteIp::API
|
||||
uncommit_and_notify_admins if api_interface?(@white_ip)
|
||||
render_success(data: { ip: { id: @white_ip.id } })
|
||||
end
|
||||
|
||||
api :PUT, '/repp/v1/white_ips/:id'
|
||||
desc 'Update whitelisted IP address'
|
||||
def update
|
||||
api = @white_ip.interfaces.include? WhiteIp::API
|
||||
previously_api = api_interface?(@white_ip)
|
||||
unless @white_ip.update(white_ip_params)
|
||||
handle_non_epp_errors(@white_ip)
|
||||
return
|
||||
end
|
||||
|
||||
notify_admins if @white_ip.interfaces.include? WhiteIp::API
|
||||
notify_admins if api && !@white_ip.interfaces.include?(WhiteIp::API)
|
||||
uncommit_and_notify_admins if api_interface?(@white_ip)
|
||||
uncommit_and_notify_admins if previously_api && !api_interface?(@white_ip)
|
||||
render_success(data: { ip: { id: @white_ip.id } })
|
||||
end
|
||||
|
||||
|
@ -58,12 +58,16 @@ module Repp
|
|||
return
|
||||
end
|
||||
|
||||
notify_admins(ip: ip, action: 'deleted') if ip.interfaces.include?(WhiteIp::API)
|
||||
uncommit_and_notify_admins(ip: ip, action: 'deleted') if ip.interfaces.include?(WhiteIp::API)
|
||||
render_success
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def api_interface?(ip)
|
||||
ip.interfaces.include? WhiteIp::API
|
||||
end
|
||||
|
||||
def find_white_ip
|
||||
@white_ip = current_user.registrar.white_ips.find(params[:id])
|
||||
end
|
||||
|
@ -72,7 +76,8 @@ module Repp
|
|||
params.require(:white_ip).permit(:address, interfaces: [])
|
||||
end
|
||||
|
||||
def notify_admins(ip: @white_ip, action: 'updated')
|
||||
def uncommit_and_notify_admins(ip: @white_ip, action: 'updated')
|
||||
@white_ip.update(committed: false) if action == 'updated'
|
||||
admin_users_emails = User.admin.pluck(:email).reject(&:blank?)
|
||||
|
||||
return if admin_users_emails.empty?
|
||||
|
|
|
@ -14,4 +14,10 @@ class WhiteIpMailer < ApplicationMailer
|
|||
subject = '[Important] Whitelisted IP Address Removal Notification'
|
||||
mail(to: email, subject: subject)
|
||||
end
|
||||
|
||||
def committed(email:, ip:)
|
||||
@white_ip = ip
|
||||
subject = 'Whitelisted IP Address Activation Confirmation'
|
||||
mail(to: email, subject: subject)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<th class="col-xs-4"><%= WhiteIp.human_attribute_name :ipv4 %></th>
|
||||
<th class="col-xs-6"><%= WhiteIp.human_attribute_name :ipv6 %></th>
|
||||
<th class="col-xs-2"><%= WhiteIp.human_attribute_name :interfaces %></th>
|
||||
<th class="col-xs-2"><%= WhiteIp.human_attribute_name :committed %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
@ -26,6 +27,7 @@
|
|||
<% end %>
|
||||
</td>
|
||||
<td><%= white_ip.interfaces.join(', ').upcase %></td>
|
||||
<td class="text-right"><%= white_ip.committed %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
|
|
@ -26,7 +26,13 @@
|
|||
.col-md-7
|
||||
= f.check_box :interfaces, { multiple: true }, x, nil
|
||||
= hidden_field_tag "white_ip[interfaces][]", nil
|
||||
.form-group
|
||||
.col-md-4.control-label
|
||||
= f.label :committed
|
||||
.col-md-7
|
||||
= f.check_box :committed
|
||||
|
||||
%hr
|
||||
.row
|
||||
.col-md-8.text-right
|
||||
= button_tag(t(:save), class: 'btn btn-primary')
|
||||
= button_tag(t(:save), class: 'btn btn-primary')
|
|
@ -22,3 +22,6 @@
|
|||
|
||||
%dt= WhiteIp.human_attribute_name :interfaces
|
||||
%dd= @white_ip.interfaces.join(', ').upcase
|
||||
|
||||
%dt= WhiteIp.human_attribute_name :committed
|
||||
%dd= @white_ip.committed
|
||||
|
|
43
app/views/mailers/white_ip_mailer/committed.html.erb
Normal file
43
app/views/mailers/white_ip_mailer/committed.html.erb
Normal file
|
@ -0,0 +1,43 @@
|
|||
Tere,
|
||||
<br><br>
|
||||
<p>
|
||||
Anname teada, et Teie konto juurde kuuluv lubatud IP-aadress on edukalt aktiveeritud.
|
||||
</p>
|
||||
<h3>IP-aadressi andmed:</h3>
|
||||
<ul>
|
||||
<li><strong>IP-aadress:</strong> <%= @white_ip.ipv4.presence || @white_ip.ipv6 %></li>
|
||||
<li><strong>Liidesed:</strong> <%= @white_ip.interfaces.join(', ') %></li>
|
||||
</ul>
|
||||
<p>
|
||||
Kõik päringud, mis algavad IP-aadressist <%= @white_ip.ipv4.presence || @white_ip.ipv6 %>, saavad meie süsteemis piiranguteta juurdepääsu.
|
||||
Palun veenduge, et hoiaksite selle IP-aadressi turvalisust ja konfidentsiaalsust, et vältida volitamata juurdepääsu.
|
||||
</p>
|
||||
Kui Teil on küsimusi seoses Teie lubatud IP-aadressi aktiveerimisega, võtke meiega ühendust.
|
||||
</p>
|
||||
<p>
|
||||
Parimate soovidega,
|
||||
</p>
|
||||
<%= render 'mailers/shared/signatures/signature.et.html' %>
|
||||
<hr>
|
||||
<br><br>
|
||||
|
||||
Hi,
|
||||
<br><br>
|
||||
<p>
|
||||
We would like to inform you that the whitelisted IP address associated with your account has been successfully activated.
|
||||
</p>
|
||||
<h3>IP address Details:</h3>
|
||||
<ul>
|
||||
<li><strong>IP address:</strong> <%= @white_ip.ipv4.presence || @white_ip.ipv6 %></li>
|
||||
<li><strong>Interfaces:</strong> <%= @white_ip.interfaces.join(', ') %></li>
|
||||
</ul>
|
||||
<p>
|
||||
All requests originating from the IP address <%= @white_ip.ipv4.presence || @white_ip.ipv6 %> will now have unrestricted access to our system.
|
||||
Please ensure the security and confidentiality of this IP address to prevent unauthorized access.
|
||||
</p>
|
||||
If you have any questions regarding the activation of your whitelisted IP address, please contact us.
|
||||
</p>
|
||||
<p>
|
||||
Best regards,
|
||||
</p>
|
||||
<%= render 'mailers/shared/signatures/signature.en.html' %>
|
32
app/views/mailers/white_ip_mailer/committed.text.erb
Normal file
32
app/views/mailers/white_ip_mailer/committed.text.erb
Normal file
|
@ -0,0 +1,32 @@
|
|||
Tere,
|
||||
|
||||
Anname teada, et Teie konto juurde kuuluv lubatud IP-aadress on edukalt aktiveeritud.
|
||||
|
||||
IP-aadressi andmed:
|
||||
- IP-aadress: <%= @white_ip.ipv4.presence || @white_ip.ipv6 %>
|
||||
- Liidesed: <%= @white_ip.interfaces.join(', ') %>
|
||||
|
||||
Kõik päringud, mis algavad IP-aadressist <%= @white_ip.ipv4.presence || @white_ip.ipv6 %>, saavad meie süsteemis piiranguteta juurdepääsu.
|
||||
Palun veenduge, et hoiaksite selle IP-aadressi turvalisust ja konfidentsiaalsust, et vältida volitamata juurdepääsu.
|
||||
|
||||
Kui Teil on küsimusi seoses Teie lubatud IP-aadressi aktiveerimisega, võtke meiega ühendust.
|
||||
|
||||
Parimate soovidega,
|
||||
<%= render 'mailers/shared/signatures/signature.et.html' %>
|
||||
---
|
||||
|
||||
Hi,
|
||||
|
||||
We would like to inform you that the whitelisted IP address associated with your account has been successfully activated.
|
||||
|
||||
IP address Details:
|
||||
- IP address: <%= @white_ip.ipv4.presence || @white_ip.ipv6 %>
|
||||
- Interfaces: <%= @white_ip.interfaces.join(', ') %>
|
||||
|
||||
All requests originating from the IP address <%= @white_ip.ipv4.presence || @white_ip.ipv6 %> will now have unrestricted access to our system.
|
||||
Please ensure the security and confidentiality of this IP address to prevent unauthorized access.
|
||||
|
||||
If you have any questions regarding the activation of your whitelisted IP address, please contact us.
|
||||
|
||||
Best regards,
|
||||
<%= render 'mailers/shared/signatures/signature.en.html' %>
|
5
db/migrate/20230707084741_add_committed_to_white_ips.rb
Normal file
5
db/migrate/20230707084741_add_committed_to_white_ips.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddCommittedToWhiteIps < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :white_ips, :committed, :boolean, default: true
|
||||
end
|
||||
end
|
|
@ -2806,7 +2806,8 @@ CREATE TABLE public.white_ips (
|
|||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
creator_str character varying,
|
||||
updator_str character varying
|
||||
updator_str character varying,
|
||||
committed boolean DEFAULT true
|
||||
);
|
||||
|
||||
|
||||
|
@ -5468,6 +5469,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||
('20221207102831'),
|
||||
('20221214073933'),
|
||||
('20221214074252'),
|
||||
('20230531111154');
|
||||
('20230531111154'),
|
||||
('20230707084741');
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue