forked from saurabh/orbit4-5
now default modules will be automatically authorized after registering of website.
This commit is contained in:
parent
2508d70883
commit
b729e32258
|
@ -138,7 +138,7 @@ var StoreManager = function(section){
|
||||||
"url" : "/admin/store/check_credentials"
|
"url" : "/admin/store/check_credentials"
|
||||||
}).done(function(status){
|
}).done(function(status){
|
||||||
if(status.success == true){
|
if(status.success == true){
|
||||||
resendEmail();
|
authorizeAllModules();
|
||||||
}else if(status.success == false){
|
}else if(status.success == false){
|
||||||
waitForStoreResponseCount++;
|
waitForStoreResponseCount++;
|
||||||
if(waitForStoreResponseCount > 5){
|
if(waitForStoreResponseCount > 5){
|
||||||
|
@ -152,6 +152,22 @@ var StoreManager = function(section){
|
||||||
}).fail(showError);
|
}).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(){
|
var resendEmail = function(){
|
||||||
loadingArea.find("img").show();
|
loadingArea.find("img").show();
|
||||||
loadingAreaStatus.text("Sending verification email.");
|
loadingAreaStatus.text("Sending verification email.");
|
||||||
|
|
|
@ -37,6 +37,33 @@ class Admin::StoreController < OrbitAdminController
|
||||||
render :json => data.to_json
|
render :json => data.to_json
|
||||||
end
|
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
|
def check_permissions
|
||||||
params_to_send = {'store_token' => current_site.store_token}
|
params_to_send = {'store_token' => current_site.store_token}
|
||||||
uri = URI.parse(@store_url)
|
uri = URI.parse(@store_url)
|
||||||
|
|
|
@ -262,6 +262,7 @@ Orbit::Application.routes.draw do
|
||||||
get "/store/check_credentials" => "store#check_credentials"
|
get "/store/check_credentials" => "store#check_credentials"
|
||||||
get "/store/register_form" => "store#register_form"
|
get "/store/register_form" => "store#register_form"
|
||||||
post "/store/register_site" => "store#register_site"
|
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/check_permissions" => "store#check_permissions"
|
||||||
get "/store/template_store" => "store#template_store"
|
get "/store/template_store" => "store#template_store"
|
||||||
get "/store/app_store" => "store#app_store"
|
get "/store/app_store" => "store#app_store"
|
||||||
|
|
Loading…
Reference in New Issue