jschat 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jschat/storage/mongo.rb +6 -1
- metadata +2 -2
data/lib/jschat/storage/mongo.rb
CHANGED
@@ -8,9 +8,13 @@ module JsChat::Storage
|
|
8
8
|
def self.connect!
|
9
9
|
@db = Mongo::Connection.new(ServerConfig['db_host'], ServerConfig['db_port']).db(ServerConfig['db_name'])
|
10
10
|
if ServerConfig['db_username'] and ServerConfig['db_password']
|
11
|
-
|
11
|
+
if @db.authenticate(ServerConfig['db_username'], ServerConfig['db_password'])
|
12
|
+
true
|
13
|
+
else
|
12
14
|
raise 'Bad Mongo username or password'
|
13
15
|
end
|
16
|
+
else
|
17
|
+
true
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
@@ -43,6 +47,7 @@ module JsChat::Storage
|
|
43
47
|
return unless Object.const_defined?(:Mongo)
|
44
48
|
connect!
|
45
49
|
rescue
|
50
|
+
p $!
|
46
51
|
puts 'Failed to connect to mongo'
|
47
52
|
false
|
48
53
|
end
|