Login assistant post processing doesn't work

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

hoanghuybao
Posts: 35
Joined: 22 Aug 2015, 16:20

Login assistant post processing doesn't work

Postby hoanghuybao » 05 Sep 2015, 11:22

Hi all,

I read tutorial Login Assistant component about at http://docs2x.smartfoxserver.com/Develo ... -assistant. I try getting an example but the method
loginData.extraFields doesn't work as I expected:

Code: Select all

        lac = new LoginAssistantComponent(this);

        // Configure the component
        lac.getConfig().loginTable = "users";
        lac.getConfig().userNameField = "username";
        lac.getConfig().passwordField = "password";
//        lac.getConfig().nickNameField = "username";
        lac.getConfig().useCaseSensitiveNameChecks = true;
//        lac.getConfig().preProcessPlugin = new LoginPreProcess();
        lac.getConfig().extraFields = Arrays.asList("permission");

        lac.getConfig().postProcessPlugin = new ILoginAssistantPlugin() {
            public void execute(LoginData loginData) {
                ISFSObject fields = loginData.extraFields;

                boolean isMod = fields.getUtfString("permission").equalsIgnoreCase("1");

                // Set client as Moderator
                if (isMod)
                    loginData.session.setProperty("$permission", DefaultPermissionProfile.MODERATOR);
            }
        };
   

Image

loginData.extraFields should contain "permission" but it contains "username" and "password" only.
This is my DB structure
Image

Anyone help me?

Regards,
Thong
hoanghuybao
Posts: 35
Joined: 22 Aug 2015, 16:20

Re: Login assistant post processing doesn't work

Postby hoanghuybao » 05 Sep 2015, 20:33

The smartfox.log shows
Skipping Unsupported SQL TYPE: -7, Column:permission
. The "permission" column has type TINYINT. I don't know reason why MYSQL shows the error message but when I try to changing the type to INT, it worked as expected.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Login assistant post processing doesn't work

Postby Lapo » 07 Sep 2015, 08:00

Hi,
I am not sure what the error is referring to, exactly:
SQL TYPE -7 refers to the JDBC type BIT, not TINYINT (whose code is -6)

In fact I don't see any problems querying a database that uses fields of TINYINT type... It could depend on the MySQL driver in use.

thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
hoanghuybao
Posts: 35
Joined: 22 Aug 2015, 16:20

Re: Login assistant post processing doesn't work

Postby hoanghuybao » 08 Sep 2015, 15:30

Hi Lapo,

I use org.gjt.mm.mysql.Driver for MYSQL driver.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Login assistant post processing doesn't work

Postby Lapo » 08 Sep 2015, 16:28

It sounds like it could be an old driver.
Recent versions use this class instead --> com.mysql.jdbc.Driver

The jar I am testing with is also quite old, to tell the truth :) It's called mysql-connector-java-5.1.12-bin and it's dated 2010.

You can download a more recent one here:
http://dev.mysql.com/downloads/connector/j/
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 22 guests