Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to give a user moderator role #84

Open
shreyasingh25 opened this issue Mar 29, 2017 · 6 comments
Open

How to give a user moderator role #84

shreyasingh25 opened this issue Mar 29, 2017 · 6 comments

Comments

@shreyasingh25
Copy link

How do we make users as moderators.
I have tried adding a record with :true under /moderators in my Firebase console, but it isn't registering that user as moderator.
Is there any other way of doing this? Or Am I missing something
screen shot 2017-03-29 at 2 54 00 pm

@katowulf
Copy link

Well, I can see that moderators are implemented, and that admin functions are bound to the UI here, so can you provide a minimal repro showing what you mean by "not registering"? That could mean just about anything, really.

Note that you do need to make sure you have security rules in place to enforce moderator privs.

@shreyasingh25
Copy link
Author

shreyasingh25 commented Mar 30, 2017

What I meant by not registering is that the user doesnt get the moderator privileges. I have noticed that when i refresh the chat, a few fields get highlighted in the realtime database, like the user, room-metadata and user-names-online, but moderators doesn't. This made me wonder if I had set the moderator in the right manner.

About the security rules, I did add for moderator -
screen shot 2017-03-30 at 9 50 01 am

Do i need to add these in some other place as well?

@katowulf
Copy link

Seems like you've done it correctly, from my limited expertise. Got a minimal repro you can share?

@shreyasingh25
Copy link
Author

shreyasingh25 commented Mar 30, 2017

This is all I have in place -

var config = {
config from firebase console here!
};

firebase.initializeApp(config);

function login() {
// Log the user in via google
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider).catch(function (error) {
console.log("Error authenticating user:", error);
});
}

firebase.auth().onAuthStateChanged(function (user) {
// Once authenticated, instantiate Firechat with the logged in user
if (user) {
initChat(user);
}
});

function initChat(user) {
// Get a Firebase Database ref
var chatRef = firebase.database().ref("chat");

// Create a Firechat instance
var chat = new FirechatUI(chatRef, document.getElementById("firechatWrapper"));

// Set the Firechat user
// user.isModerator = true;
chat.setUser(user.uid, user.displayName);

}

@alecube
Copy link

alecube commented Jan 13, 2021

Hi! it's been a long time but did you make it work? I'm having the same problem.

Thanks

@caohanh1502
Copy link

Hi! it's been a long time but did you make it work? I'm having the same problem.

Thanks

Somehow I did make it work, but idk why. I think I add one more user as moderator and it works (maybe it's because of the firebase itselft). Also don't forget to include firebase-ui.js
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants