now default modules will be automatically authorized after registering of website.

This commit is contained in:
Harry Bomrah 2015-06-02 19:54:23 +08:00
parent 2508d70883
commit b729e32258
3 changed files with 45 additions and 1 deletions

View File

@ -138,7 +138,7 @@ var StoreManager = function(section){
"url" : "/admin/store/check_credentials"
}).done(function(status){
if(status.success == true){
resendEmail();
authorizeAllModules();
}else if(status.success == false){
waitForStoreResponseCount++;
if(waitForStoreResponseCount > 5){
@ -152,6 +152,22 @@ var StoreManager = function(section){
}).fail(showError);
}
var authorizeAllModules = function(){
loadingAreaStatus.text("Authorizing default modules.");
$.ajax({
"type" : "post",
"dataType" : "json",
"url" : "/admin/store/authorize_default_modules"
}).done(function(status){
if(status.success == true){
resendEmail();
}else if(status.success == false){
loadingArea.find("img").hide();
loadingAreaStatus.text(data.message);
}
}).fail(showError);
}
var resendEmail = function(){
loadingArea.find("img").show();
loadingAreaStatus.text("Sending verification email.");

View File

@ -37,6 +37,33 @@ class Admin::StoreController < OrbitAdminController
render :json => data.to_json
end
def authorize_default_modules
modules = ModuleApp.all
ids = modules.collect{|ma| ma.key}
store_token = Site.first.store_token rescue nil
if !store_token.nil?
module_apps = ModuleApp.all
params_to_send = {'store_token' => store_token, "apps" => ids}
uri = URI.parse(OrbitStore::URL)
http = Net::HTTP.new(uri.host,uri.port)
request = Net::HTTP::Post.new("/store/register_old_sites_modules")
request.body = params_to_send.to_query
response = http.request(request) rescue nil
if response.nil?
render :json => {"success" => false, "message" => "Could not connect to the store."}.to_json
else
data = JSON.parse(response.body)
if data["success"]
render :json => {"success" => true}.to_json
elsif !data["success"]
render :json => {"success" => false, "message" => data["message"]}.to_json
end
end
else
render :json => {"success" => false, "message" => "Cannot register modules, site is not registered with store."}.to_json
end
end
def check_permissions
params_to_send = {'store_token' => current_site.store_token}
uri = URI.parse(@store_url)

View File

@ -262,6 +262,7 @@ Orbit::Application.routes.draw do
get "/store/check_credentials" => "store#check_credentials"
get "/store/register_form" => "store#register_form"
post "/store/register_site" => "store#register_site"
post "/store/authorize_default_modules" => "store#authorize_default_modules"
get "/store/check_permissions" => "store#check_permissions"
get "/store/template_store" => "store#template_store"
get "/store/app_store" => "store#app_store"