diff --git a/app/controllers/admin/register_api_controller.rb b/app/controllers/admin/register_api_controller.rb index 681b1f5..b473f1f 100644 --- a/app/controllers/admin/register_api_controller.rb +++ b/app/controllers/admin/register_api_controller.rb @@ -13,18 +13,17 @@ class Admin::RegisterApiController < ApplicationController site.admin_email = email site.generate_confirmation_token site.save - if register_client_site(site.site_token) - response["success"] = true - send_confirmation_email(site.admin_email, site.confirmation_token, site.site_token) - else - response["message"] = "Invalid site token." - response["error"] = "INVALID_SITE_TOKEN" - end + response["success"] = true else response["message"] = "Site already registered." response["error"] = "SITE_ALREADY_REGISTERED" end render :json => response.to_json + if !site.nil? + p1 = fork {register_client_site(site.site_token) } + Process.detach(p1) + end + end def send_confirmation_email(email, confirmation_token, site_token) @@ -33,6 +32,17 @@ class Admin::RegisterApiController < ApplicationController email.deliver end + def send_email + site_token = params[:store_token] + site = RegisteredSite.find_by(:uid => site_token) rescue nil + if !site.nil? + 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 + def check_permissions response = {} response["success"] = false @@ -42,7 +52,7 @@ class Admin::RegisterApiController < ApplicationController response["message"] = "Invalid site token." response["error"] = "INVALID_SITE_TOKEN" elsif !site.site_confirmed - response["message"] = "Site not confirmed, please confirm the email sent to #{site.admin_email} to proceed." + response["message"] = "Site not confirmed, please confirm the email, sent to #{site.admin_email} to proceed." response["error"] = "SITE_NOT_CONFIRMED" elsif !site.access_granted response["message"] = "Store permissions reovked." @@ -60,12 +70,12 @@ class Admin::RegisterApiController < ApplicationController request = Net::HTTP::Post.new("/store/confirmation") request.body = params_to_send.to_query response = http.request(request) - data = JSON.parse(response.body) - if data["success"] == true - return true - else - return false - end + # data = JSON.parse(response.body) + # if data["success"] == true + # return true + # else + # return false + # end end def confirm_email @@ -82,4 +92,13 @@ class Admin::RegisterApiController < ApplicationController end end -end \ No newline at end of file +end + + +# if +# response["success"] = true +# # send_confirmation_email(site.admin_email, site.confirmation_token, site.site_token) +# else +# response["message"] = "Invalid site token." +# response["error"] = "INVALID_SITE_TOKEN" +# end \ No newline at end of file diff --git a/app/views/email/site_confirmation_email.html.erb b/app/views/email/site_confirmation_email.html.erb index e69de29..7f0bd9f 100644 --- a/app/views/email/site_confirmation_email.html.erb +++ b/app/views/email/site_confirmation_email.html.erb @@ -0,0 +1,2 @@ +
Thank you for registering your site with Orbit! Please click on the following link and confirm. This is to make sure we could provide you with a spam free experience. Thanks a lot.
+ Please click to confirm \ No newline at end of file