You can simulate logging in as a user by creating a token via custom login.
For example, if your security rules are utilizing auth.uid as follows:
".write": "auth.uid == $user_id"
Then you can generate your token with the appropriate uid (plus any other details from simple login you are utilizing):
function superUserToken(USER_ID) {
var FirebaseTokenGenerator = require("firebase-token-generator");
var tokenGenerator = new FirebaseTokenGenerator(YOUR_FIREBASE_SECRET);
return tokenGenerator.createToken({uid: USER_ID});
}
Then when you want to su
to another user, just call auth() directly with the new token:
var fbRef = new Firebase(URL);
fbRef.auth( superUserToken('Kato!'), function(error, user) { /* ... */ });
This technique can also be useful for testing security rules without creating multiple accounts in your dev environment.