Page 1 of 1
privilege manager problem
Posted: 16 May 2012, 07:10
by scofy
When i set privilege activate , the addbuddy request was rejected.
My server version is sfs2x 2.0.1.
14:57:39,055 WARN [com.smartfoxserver.v2.controllers.SystemController-1] controllers.SystemController - System Request rejected: insufficient privileges. Request: AddBuddy, User: ( User Name: 10010, Id: 12, Priv: 0, Sess: 127.0.0.1:49689 )
Re: privilege manager problem
Posted: 16 May 2012, 20:07
by rjgtav
Hello. What SFS2X version are you using?
Please make sure that you have configured the privilegeManager correctly, and enabled the addBuddy request to the specific privilege level (remember that the actions you select on the privilege manager are actually the actions that are denied, not the ones that are allowed)
Finally, make sure that your user's privilege level is correctly set to a level which is able to add buddies.
Re: privilege manager problem
Posted: 23 May 2016, 08:49
by saibara
Hi buddy,
I have same problem with you, I tried to following the docs. But that script doesn't work.
Users always have same privilege.
I made this script:
Code: Select all
public class LoginHandler extends BaseServerEventHandler{
@Override
public void handleServerEvent(ISFSEvent event) throws SFSException
{
Session session = (Session) event.getParameter(SFSEventParam.SESSION);
String name = (String) event.getParameter(SFSEventParam.LOGIN_NAME);
User user = (User) event.getParameter(SFSEventParam.USER);
if(name.equals("larang") || name.equals("banned"))
{
SFSErrorData errData = new SFSErrorData(SFSErrorCode.LOGIN_BAD_USERNAME);
errData.addParameter(name);
throw new SFSLoginException("Anda dilarang masuk zone!",errData);
}
if (name.equals("SuperUser") || name.equals("admin"))
{
user.setPrivilegeId((short)3);
session.setProperty("$permission", DefaultPermissionProfile.MODERATOR);
}
trace("loginhandler class readed");
}
}
even, "loginhandler class read" not show. Do you have any idea?
Re: privilege manager problem
Posted: 23 May 2016, 15:24
by Lapo
Hi,
your code doesn't look right. In particular you're trying to obtain a "User" object in your login handler but there is no such parameter in the
LOGIN event (check the docs for more).
The User object is only created after your Login event handler has completed and based on whether you have raised an
SFSLoginException or not.
(So your code trying to access such User object will throw a NullPointerException)
As regards setting permissions the documentation is this:
http://docs2x.smartfoxserver.com/Advanc ... ge-managerSee the last section.
Thanks