summaryrefslogtreecommitdiff
path: root/lib/environment.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.de>2010-02-22 17:53:17 +0100
committerChristoph Helma <helma@in-silico.de>2010-02-22 17:53:17 +0100
commit66af8a8f648c41321189800cd81246f28d046fe6 (patch)
tree6b7e3d860209fd4bdd3af6e927f6f64ee64a15ff /lib/environment.rb
parent8946f755a1b6063d424263924acefce0d0d9d49e (diff)
parent53d755065500701a46b2a3754dc1299febe79c43 (diff)
authorisation merged from micha
Diffstat (limited to 'lib/environment.rb')
-rw-r--r--lib/environment.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/environment.rb b/lib/environment.rb
index 814e5c0..9338ca5 100644
--- a/lib/environment.rb
+++ b/lib/environment.rb
@@ -6,6 +6,7 @@ ENV['RACK_ENV'] = 'test' unless ENV['RACK_ENV']
basedir = File.join(ENV['HOME'], ".opentox")
config_dir = File.join(basedir, "config")
config_file = File.join(config_dir, "#{ENV['RACK_ENV']}.yaml")
+user_file = File.join(config_dir, "users.yaml")
TMP_DIR = File.join(basedir, "tmp")
LOG_DIR = File.join(basedir, "log")
@@ -44,6 +45,21 @@ logfile = "#{LOG_DIR}/#{ENV["RACK_ENV"]}.log"
LOGGER = Logger.new(logfile,'daily') # daily rotation
LOGGER.level = Logger::DEBUG
+if File.exist?(user_file)
+ @@users = YAML.load_file(user_file)
+else
+ FileUtils.cp(File.join(File.dirname(__FILE__), 'templates/users.yaml'), user_file)
+ puts "Please edit #{user_file} and restart your application."
+ exit
+end
+
+begin
+ 0 < @@users[:users].keys.length
+rescue
+ puts "Please edit #{user_file} and restart your application. Create at least one user with password."
+ exit
+end
+
# RDF namespaces
RDF = Redland::Namespace.new 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
OWL = Redland::Namespace.new 'http://www.w3.org/2002/07/owl#'