Merge branch 'master' into 'master'

fix register site when website to register is https or ssl expired.

from ruling.digital version.(gemspec)
fix register site when website to register is https or ssl expired.
add resend email to not confirmed email.

See merge request !1
This commit is contained in:
chiu 2020-02-12 16:36:19 +08:00
commit 5365d6bcca
5 changed files with 43 additions and 24 deletions

View File

@ -28,14 +28,21 @@ class Admin::RegisterApiController < ApplicationController
response["message"] = "Site already registered." response["message"] = "Site already registered."
response["error"] = "SITE_ALREADY_REGISTERED" response["error"] = "SITE_ALREADY_REGISTERED"
end end
render :json => response.to_json
if !site.nil? if !site.nil?
p1 = fork {register_client_site(site.site_token) } p1 = fork {register_client_site(site.site_token) }
Process.detach(p1) Process.detach(p1)
end end
render :json => ((params[:success] == 'error') ? response.merge({'success'=>params[:success]}).to_json : response.to_json)
end end
def send_store_token
site = RegisteredSite.where(:site_domain => params[:site_domain]).first
if !site.nil?
render :json => {'store_token'=>site.uid}
else
render :json => {'store_token'=>nil}
end
end
def send_confirmation_email(email, confirmation_token, site_token) def send_confirmation_email(email, confirmation_token, site_token)
url = "#{request.protocol}#{request.host_with_port}/register/confirm_email?confirmation=#{confirmation_token}&site=#{site_token}" url = "#{request.protocol}#{request.host_with_port}/register/confirm_email?confirmation=#{confirmation_token}&site=#{site_token}"
email = Email.new(:mail_to => email, :mail_subject => "Confirmation email for orbit store.", :template => "email/site_confirmation_email.html.erb", :template_data => {"url" => url}) email = Email.new(:mail_to => email, :mail_subject => "Confirmation email for orbit store.", :template => "email/site_confirmation_email.html.erb", :template_data => {"url" => url})
@ -47,10 +54,8 @@ class Admin::RegisterApiController < ApplicationController
site = RegisteredSite.find_by(:uid => site_token) rescue nil site = RegisteredSite.find_by(:uid => site_token) rescue nil
if !site.nil? if !site.nil?
send_confirmation_email(site.admin_email, site.confirmation_token, site.site_token) send_confirmation_email(site.admin_email, site.confirmation_token, site.site_token)
render :json => {"success" => true}.to_json
else
render :json => {"success" => false}.to_json
end end
redirect_to :back
end end
def re_register_url def re_register_url
@ -82,7 +87,7 @@ class Admin::RegisterApiController < ApplicationController
else else
response["success"] = true response["success"] = true
end end
render :json => response.to_json render :json => ((params[:success] == 'error') ? response.merge(params).to_json : response.to_json)
end end
def register_client_site(store_token) def register_client_site(store_token)
@ -91,8 +96,17 @@ class Admin::RegisterApiController < ApplicationController
http = Net::HTTP.new(uri.host,uri.port) http = Net::HTTP.new(uri.host,uri.port)
request = Net::HTTP::Post.new("/store/confirmation") request = Net::HTTP::Post.new("/store/confirmation")
request.body = params_to_send.to_query request.body = params_to_send.to_query
begin
response = http.request(request) response = http.request(request)
if response.code == '200'
return response return response
else
response = Net::HTTP.post_form(URI("https://#{params[:site_domain]}/store/confirmation"),params_to_send) #if response.code == 301,use https to resend /store/confirmation
return response
end
rescue
params[:success] = 'error'
end
end end
def confirm_email def confirm_email

View File

@ -43,7 +43,7 @@
</td> </td>
<td> <td>
<% if !site.site_confirmed %> <% if !site.site_confirmed %>
<a class="btn btn-success" disabled="disabled"> Grant </a> <a class="btn btn-success" href="<%='/site/send_email?store_token='+site.uid%>"> <%=t('resend_email')%></a>
<% elsif !site.access_granted %> <% elsif !site.access_granted %>
<a href="/admin/registered_site/change_access/<%= site.site_token %>?status=grant<%= "&page=#{params[:page]}" if params[:page]%><%= "&keywords=#{params[:keywords]}" if params[:keywords] %>" class="btn btn-success" data-remote="true">Grant</a> <a href="/admin/registered_site/change_access/<%= site.site_token %>?status=grant<%= "&page=#{params[:page]}" if params[:page]%><%= "&keywords=#{params[:keywords]}" if params[:keywords] %>" class="btn btn-success" data-remote="true">Grant</a>
<% else %> <% else %>

View File

@ -3,6 +3,7 @@ en:
admin_email: Admin Email admin_email: Admin Email
status: Status status: Status
permission: Access permission: Access
resend_email: Resend email
registered_sites: registered_sites:
customization_log: Customization Log customization_log: Customization Log
registered_sites: Registered Sites registered_sites: Registered Sites

View File

@ -3,6 +3,7 @@ zh_tw:
admin_email: Admin Email admin_email: Admin Email
status: Status status: Status
permission: Access permission: Access
resend_email: Resend email
registered_sites: registered_sites:
customization_log: Customization Log customization_log: Customization Log
registered_sites: Registered Sites registered_sites: Registered Sites

View File

@ -1,19 +1,22 @@
$:.push File.expand_path("../lib", __FILE__) # -*- encoding: utf-8 -*-
# stub: registered_sites 0.0.1 ruby lib
# Maintain your gem's version:
require "registered_sites/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "registered_sites" s.name = "registered_sites"
s.version = RegisteredSites::VERSION s.version = "0.0.1"
s.authors = ["Rulingcom"]
s.email = ["harry@rulingcom.com"]
s.homepage = "http://www.rulingcom.com"
s.summary = "Manage registered sites."
s.description = "Manage registered sites."
s.license = "MIT"
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.test_files = Dir["test/**/*"] s.require_paths = ["lib"]
s.authors = ["Rulingcom"]
s.date = "2019-03-28"
s.description = "Manage registered sites."
s.email = ["harry@rulingcom.com"]
s.files = ["MIT-LICENSE", "README.rdoc", "Rakefile", "app/assets/images/registered_sites", "app/assets/javascripts/registered_site_progress.js", "app/assets/javascripts/registered_sites", "app/assets/javascripts/registered_sites/application.js", "app/assets/stylesheets/registered_site_progress.css.scss", "app/assets/stylesheets/registered_sites", "app/assets/stylesheets/registered_sites/application.css", "app/controllers/admin/customization_logs_controller.rb", "app/controllers/admin/register_api_controller.rb", "app/controllers/admin/registered_sites_controller.rb", "app/controllers/registered_sites_controller.rb", "app/helpers/registered_sites", "app/helpers/registered_sites/application_helper.rb", "app/models/registered_site.rb", "app/models/site_log.rb", "app/models/site_log_file.rb", "app/views/admin/customization_logs", "app/views/admin/customization_logs/_form.html.erb", "app/views/admin/customization_logs/_form_file.html.erb", "app/views/admin/customization_logs/_index.html.erb", "app/views/admin/customization_logs/_log_modal.html.erb", "app/views/admin/customization_logs/edit.html.erb", "app/views/admin/customization_logs/get_log.html.erb", "app/views/admin/customization_logs/index.html.erb", "app/views/admin/customization_logs/new.html.erb", "app/views/admin/register_api", "app/views/admin/register_api/confirm_email.html.erb", "app/views/admin/registered_sites", "app/views/admin/registered_sites/_form.html.erb", "app/views/admin/registered_sites/_index.html.erb", "app/views/admin/registered_sites/change_access_status.js.erb", "app/views/admin/registered_sites/destroy.js.erb", "app/views/admin/registered_sites/edit.html.erb", "app/views/admin/registered_sites/index.html.erb", "app/views/admin/registered_sites/progress.html.erb", "app/views/email/site_confirmation_email.html.erb", "config/locales/en.yml", "config/locales/zh_tw.yml", "config/routes.rb", "lib/registered_sites", "lib/registered_sites.rb", "lib/registered_sites/engine.rb", "lib/registered_sites/version.rb", "lib/tasks/registered_sites_tasks.rake", "test/dummy", "test/dummy/README.rdoc", "test/dummy/Rakefile", "test/dummy/app", "test/dummy/app/assets", "test/dummy/app/assets/images", "test/dummy/app/assets/javascripts", "test/dummy/app/assets/javascripts/application.js", "test/dummy/app/assets/stylesheets", "test/dummy/app/assets/stylesheets/application.css", "test/dummy/app/controllers", "test/dummy/app/controllers/application_controller.rb", "test/dummy/app/controllers/concerns", "test/dummy/app/helpers", "test/dummy/app/helpers/application_helper.rb", "test/dummy/app/mailers", "test/dummy/app/models", "test/dummy/app/models/concerns", "test/dummy/app/views", "test/dummy/app/views/layouts", "test/dummy/app/views/layouts/application.html.erb", "test/dummy/bin", "test/dummy/bin/bundle", "test/dummy/bin/rails", "test/dummy/bin/rake", "test/dummy/config", "test/dummy/config.ru", "test/dummy/config/application.rb", "test/dummy/config/boot.rb", "test/dummy/config/database.yml", "test/dummy/config/environment.rb", "test/dummy/config/environments", "test/dummy/config/environments/development.rb", "test/dummy/config/environments/production.rb", "test/dummy/config/environments/test.rb", "test/dummy/config/initializers", "test/dummy/config/initializers/assets.rb", "test/dummy/config/initializers/backtrace_silencers.rb", "test/dummy/config/initializers/cookies_serializer.rb", "test/dummy/config/initializers/filter_parameter_logging.rb", "test/dummy/config/initializers/inflections.rb", "test/dummy/config/initializers/mime_types.rb", "test/dummy/config/initializers/session_store.rb", "test/dummy/config/initializers/wrap_parameters.rb", "test/dummy/config/locales", "test/dummy/config/locales/en.yml", "test/dummy/config/routes.rb", "test/dummy/config/secrets.yml", "test/dummy/lib", "test/dummy/lib/assets", "test/dummy/log", "test/dummy/public", "test/dummy/public/404.html", "test/dummy/public/422.html", "test/dummy/public/500.html", "test/dummy/public/favicon.ico", "test/integration/navigation_test.rb", "test/registered_sites_test.rb", "test/test_helper.rb"]
s.homepage = "http://www.rulingcom.com"
s.licenses = ["MIT"]
s.rubygems_version = "2.2.2"
s.summary = "Manage registered sites."
s.test_files = ["test/dummy", "test/dummy/README.rdoc", "test/dummy/bin", "test/dummy/bin/bundle", "test/dummy/bin/rake", "test/dummy/bin/rails", "test/dummy/log", "test/dummy/app", "test/dummy/app/assets", "test/dummy/app/assets/javascripts", "test/dummy/app/assets/javascripts/application.js", "test/dummy/app/assets/images", "test/dummy/app/assets/stylesheets", "test/dummy/app/assets/stylesheets/application.css", "test/dummy/app/mailers", "test/dummy/app/helpers", "test/dummy/app/helpers/application_helper.rb", "test/dummy/app/controllers", "test/dummy/app/controllers/application_controller.rb", "test/dummy/app/controllers/concerns", "test/dummy/app/views", "test/dummy/app/views/layouts", "test/dummy/app/views/layouts/application.html.erb", "test/dummy/app/models", "test/dummy/app/models/concerns", "test/dummy/Rakefile", "test/dummy/lib", "test/dummy/lib/assets", "test/dummy/public", "test/dummy/public/422.html", "test/dummy/public/500.html", "test/dummy/public/favicon.ico", "test/dummy/public/404.html", "test/dummy/config.ru", "test/dummy/config", "test/dummy/config/environments", "test/dummy/config/environments/production.rb", "test/dummy/config/environments/development.rb", "test/dummy/config/environments/test.rb", "test/dummy/config/environment.rb", "test/dummy/config/database.yml", "test/dummy/config/boot.rb", "test/dummy/config/routes.rb", "test/dummy/config/application.rb", "test/dummy/config/secrets.yml", "test/dummy/config/locales", "test/dummy/config/locales/en.yml", "test/dummy/config/initializers", "test/dummy/config/initializers/wrap_parameters.rb", "test/dummy/config/initializers/cookies_serializer.rb", "test/dummy/config/initializers/mime_types.rb", "test/dummy/config/initializers/assets.rb", "test/dummy/config/initializers/inflections.rb", "test/dummy/config/initializers/backtrace_silencers.rb", "test/dummy/config/initializers/filter_parameter_logging.rb", "test/dummy/config/initializers/session_store.rb", "test/test_helper.rb", "test/registered_sites_test.rb", "test/integration/navigation_test.rb"]
s.installed_by_version = "2.2.2" if s.respond_to? :installed_by_version
end end