Class: InstallerController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- InstallerController
- Includes:
- PluginHelper
- Defined in:
- app/controllers/installer_controller.rb
Constant Summary collapse
- APP_CONFIG =
Load configuration items (MANDATORY, must be included)
HashWithIndifferentAccess.new(YAML.load(File.read(File.('../../../config/podio/podio_config.yml', __FILE__))))
Instance Method Summary collapse
-
#before_process ⇒ Object
Used for initializing and creating database entries.
-
#core_process ⇒ Object
Used for logical processing.
-
#post_process ⇒ Object
Used for configuring data.
-
#uninstall ⇒ Object
Uninstaller.
Methods included from PluginHelper
#current_user, #get_current_user_role
Instance Method Details
#before_process ⇒ Object
Used for initializing and creating database entries
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/installer_controller.rb', line 14 def before_process begin SymmetricEncryption.load! if (@curUserRole == 'contentadmin' || @curUserRole == 'user' || @curUserRole == 'anonymous' || @curUserRole == 'loggedin') raise 'unauthorized access' end if (!Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:SERVICE_ACCOUNT_NAME], session[:accessible_appid]] }).nil?) Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:SERVICE_ACCOUNT_NAME], session[:accessible_appid]] }).destroy end if (!Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:SERVICE_ACCOUNT_PASS], session[:accessible_appid]] }).nil?) Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:SERVICE_ACCOUNT_PASS], session[:accessible_appid]] }).destroy end if (!Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:PODIO_API_KEY], session[:accessible_appid] ]}).nil?) Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:PODIO_API_KEY], session[:accessible_appid] ]}).destroy end if (!Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:PODIO_SECRET_KEY], session[:accessible_appid]] }).nil?) Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:PODIO_SECRET_KEY], session[:accessible_appid]] }).destroy end currentWorkspaceMetadata = Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:PODIO_WORKSPACE], session[:accessible_appid]] }) if (!currentWorkspaceMetadata.nil?) currentWorkspaceMetadata.destroy end Metadata.create({ :key => APP_CONFIG[:SERVICE_ACCOUNT_NAME], :value => params[:serviceAccountName].strip, :cat => 'podio_config', :mime => 'text/plain', :sites_id => session[:accessible_appid] }) Metadata.create({ :key => APP_CONFIG[:SERVICE_ACCOUNT_PASS], :value => SymmetricEncryption.encrypt(params[:serviceAccountPass].strip), :cat => 'podio_config', :mime => 'text/plain', :sites_id => session[:accessible_appid] }) Metadata.create({ :key => APP_CONFIG[:PODIO_API_KEY], :value => params[:podioApiKey].strip, :cat => 'podio_config', :mime => 'text/plain', :sites_id => session[:accessible_appid] }) Metadata.create({ :key => APP_CONFIG[:PODIO_SECRET_KEY], :value => params[:podioSecretKey].strip, :cat => 'podio_config', :mime => 'text/plain', :sites_id => session[:accessible_appid] }) render :json => { :status => 'success' } rescue render :json => { :status => 'failure' } end end |
#core_process ⇒ Object
Used for logical processing
79 80 81 |
# File 'app/controllers/installer_controller.rb', line 79 def core_process render :json => { :status => 'unimplemented' } end |
#post_process ⇒ Object
Used for configuring data
84 85 86 |
# File 'app/controllers/installer_controller.rb', line 84 def post_process render :json => { :status => 'unimplemented' } end |
#uninstall ⇒ Object
Uninstaller
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'app/controllers/installer_controller.rb', line 89 def uninstall begin if (@curUserRole == 'contentadmin' || @curUserRole == 'user' || @curUserRole == 'anonymous' || @curUserRole == 'loggedin') raise 'unauthorized access' end if (!Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:SERVICE_ACCOUNT_NAME], session[:accessible_appid]] }).nil?) Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:SERVICE_ACCOUNT_NAME], session[:accessible_appid]] }).destroy end if (!Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:SERVICE_ACCOUNT_PASS], session[:accessible_appid]] }).nil?) Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:SERVICE_ACCOUNT_PASS], session[:accessible_appid]] }).destroy end if (!Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:PODIO_API_KEY], session[:accessible_appid] ]}).nil?) Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:PODIO_API_KEY], session[:accessible_appid] ]}).destroy end if (!Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:PODIO_SECRET_KEY], session[:accessible_appid]] }).nil?) Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:PODIO_SECRET_KEY], session[:accessible_appid]] }).destroy end currentWorkspaceMetadata = Metadata.first({ :conditions => ['key = ? and sites_id = ?', APP_CONFIG[:PODIO_WORKSPACE], session[:accessible_appid]] }) if (!currentWorkspaceMetadata.nil?) currentWorkspaceMetadata.destroy end render :json => { :status => 'success' } rescue render :json => { :status => 'failure' } end end |