privilege manager problem

Post here your questions about the Objective-C API for SFS2X

Moderators: Lapo, Bax

scofy
Posts: 79
Joined: 08 Apr 2012, 09:04

privilege manager problem

Postby scofy » 16 May 2012, 07:10

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 )
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: privilege manager problem

Postby rjgtav » 16 May 2012, 20:07

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.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
User avatar
saibara
Posts: 13
Joined: 04 May 2016, 08:52
Contact:

Re: privilege manager problem

Postby saibara » 23 May 2016, 08:49

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?
User avatar
Lapo
Site Admin
Posts: 19602
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: privilege manager problem

Postby Lapo » 23 May 2016, 15:24

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-manager

See the last section.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X iPhone / iPad / OSX API”

Who is online

Users browsing this forum: No registered users and 2 guests