 
 
         // implement this later
-//        if let userAndPass = userAndPass {
-//            
-//            mongo_cmd_authenticate(self.connection!, self.databaseName, userAndPass.0, userAndPass.1)
-//        }
+        if let userAndPass = userAndPass {
+            self.login(username: userAndPass.username, password: userAndPass.password)
+        }
+    }
+    
+    public func login(username username: String, password: String) {
+        mongo_cmd_authenticate(self.connection!, self.db, username, password)
     }
     
     /**
     Initates the mongodb connection to the default host and port (usually localhost:27017)
     */
-    public convenience init(database: String, usernameAndPassword userAndPass:(String,String)? = nil) {
+    public convenience init(database: String, usernameAndPassword userAndPass:(username: String, password: String)? = nil) {
         
         self.init(host: Helpers.getIPAddress(), port: 27017, database: database, usernameAndPassword: userAndPass)
-        
+
+
+        if let userAndPass = userAndPass {
+            self.login(username: userAndPass.username, password: userAndPass.password)
+        }
     }
     
     /**


        self.collections.insert(collection)
    }
}

    
    internal var connection: UnsafeMutablePointer<mongo>? = mongo_alloc()

    internal var databaseName: String
    
    public var db: String { // read only
        get {
            return self.databaseName
        }
    }
    
    public func changeDB(databaseName: String) {
        self.databaseName = databaseName
    }

    internal var collections = Set<MongoCollection>()
    

