Edit verification code error.

This commit is contained in:
BoHung Chiu 2021-04-14 19:44:06 +08:00
parent 31659c6860
commit 05013dd99a
2 changed files with 33 additions and 6 deletions

View File

@ -178,11 +178,33 @@ class SeminarsController < ApplicationController
if !@signup.blank? if !@signup.blank?
redirect_to "#{params[:referer_url]}", :notice => 'mail已存在' redirect_to "#{params[:referer_url]}", :notice => 'mail已存在'
else else
redirect_to "#{params[:referer_url]}", :notice => t('recaptcha.errors.verification_failed') referer_url = params[:referer_url].to_s
if referer_url.split("/").last.include?("?")
uri_query = referer_url.split("?").last.gsub(/notice=[^&]*/,'')
if uri_query == ""
referer_url = referer_url.split("?")[0...-1].join("?") + "?notice=#{t('recaptcha.errors.verification_failed')}"
else
referer_url = referer_url.split("?")[0...-1].join("?") + "&notice=#{t('recaptcha.errors.verification_failed')}"
end
else
referer_url = referer_url + "?notice=#{t('recaptcha.errors.verification_failed')}"
end
redirect_to referer_url, :notice => t('recaptcha.errors.verification_failed')
end end
end end
else else
redirect_to "#{params[:referer_url]}", :notice => t('recaptcha.errors.verification_failed') referer_url = params[:referer_url].to_s
if referer_url.split("/").last.include?("?")
uri_query = referer_url.split("?").last.gsub(/notice=[^&]*/,'')
if uri_query == ""
referer_url = referer_url.split("?")[0...-1].join("?") + "?notice=#{t('recaptcha.errors.verification_failed')}"
else
referer_url = referer_url.split("?")[0...-1].join("?") + "&notice=#{t('recaptcha.errors.verification_failed')}"
end
else
referer_url = referer_url + "?notice=#{t('recaptcha.errors.verification_failed')}"
end
redirect_to referer_url, :notice => t('recaptcha.errors.verification_failed')
end end
end end

View File

@ -12,12 +12,17 @@
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %> <%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/date.time.picker.js" %> <%= javascript_include_tag "lib/datetimepicker/date.time.picker.js" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<% notice = flash["notice"] || params[:notice] %>
<% flash.each do |key, msg| %> <% flash.each do |key, msg| %>
<%= content_tag :p, msg, :class => [key, "alert alert-error in fade"] %> <% next if key.to_s == "notice" %>
<%= content_tag :p, msg, :class => [key, "alert alert-error in fade"], :style => "color: red; font-weight: bold;" %>
<% end %>
<% if notice.present? %>
<%= content_tag :p, params[:notice], :class => ["notice alert alert-error in fade"], :style => "color: red; font-weight: bold;" %>
<script type="text/javascript">
window.alert("<%=notice%>");
</script>
<% end %> <% end %>
<%= form_for @seminar_signup, url: seminars_path, html: {class: "content form-horizontal" , :id=>"new-seminar-signup"} do |f| %> <%= form_for @seminar_signup, url: seminars_path, html: {class: "content form-horizontal" , :id=>"new-seminar-signup"} do |f| %>
<fieldset> <fieldset>