test for registered site
This commit is contained in:
parent
8e44b7c3a8
commit
727d775d7b
|
@ -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
|
||||
|
@ -83,3 +93,12 @@ class Admin::RegisterApiController < ApplicationController
|
|||
end
|
||||
|
||||
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
|
|
@ -0,0 +1,2 @@
|
|||
<p>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.</p>
|
||||
<a href="<%= @data['url'] %>" > Please click to confirm </a>
|
Loading…
Reference in New Issue