Changing userrole in active session?

62 views
Skip to first unread message

Das Plasma

unread,
Feb 19, 2015, 10:23:38 AM2/19/15
to ajax...@googlegroups.com
I'm currently investigating a way to implement a function to muzzle users. (like -v in a moderatored IRC channel)
To keep it easy, the idea is to set them to the new usergroup "custom_user", userrole 5 and deny this group to send new chat messages.

Do you see any problem to do this during an active session?
Just like changing the nickname, for example...

By the way... anyone interested in a mod i wrote for my SMF integrated chat, that allows to set permissions to users to post images?
The permission is set using a special SMF member group.
With my mod guests are generally not allowed to use the IMG-tag for security purposes... to avoid guests getting other users (or even mod+) IP addresses.

Frug

unread,
Feb 22, 2015, 3:33:44 PM2/22/15
to ajax...@googlegroups.com
It will probably be tricky to change a user's role without having them log out and in again. 
Their role is stored in the SMF db and while you can force a different role in chat, that's done (I think) during the call to getValidLoginUserData() which is only fired on login. You'll have to hack in a way to force their session to change and that's pretty tricky. I think what you'll need to do is hack the initMessageHandling() or the insertMessage() functions and add another check there. I think initMessageHandling() is designed for that but you'll have to test it out if it fires on every message like you want.
That check will have to consult something, like the database, to see if you've muted that user. It would be a good place to reset their group in their session. Other users won't see that the person's group has changed unless you also send out some XML update to tell everyone that someone's group has changed. 

You could also do it on every chat load (ie: every poll request for messages anyone makes), even before they try to insert a message, but that would add some overhead that might slow chat down.

Markis Cook

unread,
Jun 3, 2015, 2:30:58 PM6/3/15
to ajax...@googlegroups.com
The closest I have gotten to doing anything along the lines of changing a user's role on the fly is with this admin/mod escalation mod that I made.  It uses the command system to upgrade a normal user to an Admin or a Moderator.  Basically the command is a 'password' that is unknown to the users and thus remains safe to implement.  As far as you changing another users role on the fly, I am actually currently working on a mod to do that.  I will share link you to my Admin/Mod Escalation Mod that I made (it's uploaded to Frug's Github currently):

https://github.com/Frug/AJAX-Chat/wiki/Mod-Moderator-Admin-Escalation
Reply all
Reply to author
Forward
0 new messages