Created
July 10, 2011 00:01
-
-
Save s9tpepper/1074076 to your computer and use it in GitHub Desktop.
Authenticating with a database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onDBConnected(db:DB):void | |
{ | |
/* First create a Credentials object using your username/password */ | |
var dbCredentials:Credentials = new Credentials("db_user_name", "db_user_password"); | |
/* Add callback handlers for authentication problems and authenticated | |
Signals objects */ | |
mongo.db("myDatabase").authenticationProblem.add(onAuthenticationProblem); | |
mongo.db("myDatabase").authenticated.add(onDBAuthenticated); | |
/* Set the credentials to the database */ | |
mongo.db("myDatabase").setCredentials(dbCredentials); | |
/* Run the authenticate mongodb command */ | |
mongo.db("myDatabase").authenticate(); | |
} | |
function onAuthenticationProblem(db:DB):void | |
{ | |
trace("There was a problem authenticating with the database."); | |
} | |
function onDBAuthenticated(db:DB):void | |
{ | |
/*...do stuff...*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment