 
 
         // 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)
    }
}

    - parameter database:    The database, ex: 'test'
    - parameter userAndPass: The username and password for the user in the format (username, password) - optional.
    */
    public init(host: String, port: Int, database: String, usernameAndPassword userAndPass:(username: String, password: String)? = nil) {
        
        mongo_init(self.connection!)

        let status = mongo_client(self.connection!, host, Int32(port))

        if status != MONGO_OK {
            print("connection failed")
            mongo_destroy(self.connection!)
