diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-02-07 10:27:22 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-02-07 10:27:22 -0500 |
commit | 5b8a108923fa9b706bc062b35f558121f672d0e3 (patch) | |
tree | 1e524ac049af7fafb83dd78f798c4a7464cd85c5 | |
parent | 9590e60f21a474ef7b99a0ce65ff3d5fbe70f3c6 (diff) | |
download | mongo-5b8a108923fa9b706bc062b35f558121f672d0e3.tar.gz |
removeUser
-rw-r--r-- | jstests/auth.js | 7 | ||||
-rw-r--r-- | shell/db.js | 5 |
2 files changed, 11 insertions, 1 deletions
diff --git a/jstests/auth.js b/jstests/auth.js index 6d9fd68caa4..10fbb11bbca 100644 --- a/jstests/auth.js +++ b/jstests/auth.js @@ -17,6 +17,10 @@ db.addUser( "eliot" , pass2 ); assert( ! db.auth( "eliot" , pass ) , "failed to change password failed" ); assert( db.auth( "eliot" , pass2 ) , "new password didn't take" ); +assert( db.auth( "eliot" , pass2 ) , "what?" ); +db.removeUser( "eliot" ); +assert( ! db.auth( "eliot" , pass2 ) , "didn't remove user" ); + var a = db.getMongo().getDB( "admin" ); users = a.getCollection( "system.users" ); @@ -24,4 +28,5 @@ users.remove( {} ); pass = "c" + Math.random(); a.addUser( "super", pass ); assert( a.auth( "super" , pass ) , "auth failed" ); -assert( !a.auth( "super" , pass + "a" ) , "auth should have failed" );
\ No newline at end of file +assert( !a.auth( "super" , pass + "a" ) , "auth should have failed" ); + diff --git a/shell/db.js b/shell/db.js index 9c033048689..5ecb5174625 100644 --- a/shell/db.js +++ b/shell/db.js @@ -41,6 +41,10 @@ DB.prototype.addUser = function( username , pass ){ c.save( u ); } +DB.prototype.removeUser = function( username ){ + this.getCollection( "system.users" ).remove( { user : username } ); +} + DB.prototype.auth = function( username , pass ){ var n = this.runCommand( { getnonce : 1 } ); @@ -178,6 +182,7 @@ DB.prototype.help = function() { print("\tdb.getCollection(cname) same as db['cname'] or db.cname"); print("\tdb.runCommand(cmdObj) run a database command. if cmdObj is a string, turns it into { cmdObj : 1 }"); print("\tdb.addUser(username, password)"); + print("\tdb.removeUser(username)"); print("\tdb.createCollection(name, { size : ..., capped : ..., max : ... } )"); print("\tdb.getReplicationInfo()"); print("\tdb.getProfilingLevel()"); |