u4819210 / social-networks-for-fun

Automatically exported from code.google.com/p/social-networks-for-fun
0 stars 0 forks source link

session ID from login results in wrong group list from mygroups #40

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm not getting the right group list from iPhone, so I tested with curl, you 
can reproduce with this:

curl -c ~/tmp/cookies -d "username=JohnLiu&password=yes" 
http://localhost:8080/prototype-socialrays-jersey/UserResources/login
{"banned":"no","code":"99999","email":"a@b.com","guid":"894","language":"en","la
stAction":"0","lastLogin":"0","loginTime":"2010-08-30T23:07:13-07:00","name":"Jo
hn 
Liu","password":"1553f12839fe5a7043b05b107bdd8448","passwordValid":"true","prevL
astAction":"0","prevLastLogin":"0","salt":"4ec7df16","userValid":"true","usernam
e":"JohnLiu"}

Notice the username is JohnLiu, ID is 894.

cat ~/tmp/cookies
# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

localhost   FALSE   /prototype-socialrays-jersey    FALSE   0   JSESSIONID  1da198bc120d47c1
48f0dc1e2944

curl -G -b "JSESSIONID=1da198bc120d47c148f0dc1e2944" -H Accept:application/json 
-H Content-type:application/json 
http://localhost:8080/prototype-socialrays-jersey/group/mygroups

{"list":{"closed":"false","guid":"9","name":"1283018611671","owner":{"banned":"n
o","code":"99999","email":"a@c.com","guid":"895","language":"en","lastAction":"0
","lastLogin":"0","loginTime":"2010-08-30T23:13:20-07:00","name":"John Liu 
1","password":"f8f14e2a582d484116eef494b5f0a8a2","passwordValid":"true","prevLas
tAction":"0","prevLastLogin":"0","salt":"8d4fa3d7","userValid":"true","username"
:"JohnLiu1"},"siteId":"0"}}

Notice the list returned has owner "JohnLiu1" with ID 895.

Original issue reported on code.google.com by johnliu...@gmail.com on 2 Sep 2010 at 10:00

GoogleCodeExporter commented 8 years ago
More info: 

In database elgg3. look at table elgg_group_entity, user 894 owns 2 groups 24 
and 25. user 895 owns one group 9.

Original comment by johnliu...@gmail.com on 2 Sep 2010 at 10:07

GoogleCodeExporter commented 8 years ago
This issue was updated by revision r69.

Revert a change made to GroupService.

Original comment by zhangyon...@gmail.com on 2 Sep 2010 at 1:37

GoogleCodeExporter commented 8 years ago
(The commit comment for revision r69 should not go to here. It should go to 
another issue. This issue should be still pending, not fixed )

Original comment by zhangyon...@gmail.com on 2 Sep 2010 at 2:09

GoogleCodeExporter commented 8 years ago
New code to fix this issue has been checked in. Mark this bug as fixed. Please 
verify. If it's there, please reopen this issue. If fixed, please close this 
issue.

Original comment by zhangyon...@gmail.com on 2 Sep 2010 at 2:43

GoogleCodeExporter commented 8 years ago
This issue was updated by revision r70.

Not sure about the HibernateQL join statement. Replaced with direct sql.

Login test command: 

curl -c /tmp/cookies -d "username=JohnLiu&password=yes" 
http://localhost:8080/socialrays-lbs-server-web/UserResources/login{"banned":"no
","code":"99999","email":"a@b.com","guid":"894","language":"en","lastAction":"0"
,"lastLogin":"0","loginTime":"2010-08-30T23:07:13-07:00","name":"John 
Liu","password":"1553f12839fe5a7043b05b107bdd8448","passwordValid":"true","prevL
astAction":"0","prevLastLogin":"0","salt":"4ec7df16","userValid":"true","usernam
e":"JohnLiu"}

servicesat-lm:lbs-web chzhang$ cat /tmp/cookies # Netscape HTTP Cookie File
localhost   FALSE   /socialrays-lbs-server-web  FALSE   0   JSESSIONID  1eorxxgsswpq0f5lbs
42p0h1a

Curl to get my groups:

curl -G -b "JSESSIONID=1eorxxgsswpq0f5lbs42p0h1a" -H Accept:application/json -H 
Content-type:application/json http://localhost:8080/........./group/mygroups
{"list":[{"closed":"false","guid":"9","name":"1283018611671","owner":{"banned":"
no","code":"99999","email":"a@c.com","guid":"895","language":"en","lastAction":"
0","lastLogin":"0","loginTime":"2010-08-30T23:13:20-07:00","name":"John Liu 
1","password":"f8f14e2a582d484116eef494b5f0a8a2","passwordValid":"true","prevLas
tAction":"0","prevLastLogin":"0","salt":"8d4fa3d7","userValid":"true","username"
:"JohnLiu1"},"siteId":"0"},{"closed":"false","guid":"24","name":"aother 
group","owner":{"banned":"no","code":"99999","email":"a@b.com","guid":"894","lan
guage":"en","lastAction":"0","lastLogin":"0","loginTime":"2010-08-30T23:07:13-07
:00","name":"John 
Liu","password":"1553f12839fe5a7043b05b107bdd8448","passwordValid":"true","prevL
astAction":"0","prevLastLogin":"0","salt":"4ec7df16","userValid":"true","usernam
e":"JohnLiu"},"siteId":"0"},{"closed":"false","guid":"25","name":"newgroup","own
er":{"banned":"no","code":"99999","email":"a@b.com","guid":"894","language":"en"
,"lastAction":"0","lastLogin":"0","loginTime":"2010-08-30T23:07:13-07:00","name"
:"John 
Liu","password":"1553f12839fe5a7043b05b107bdd8448","passwordValid":"true","prevL
astAction":"0","prevLastLogin":"0","salt":"4ec7df16","userValid":"true","usernam
e":"JohnLiu"},"siteId":"0"}]}

Now 3 groups returned. JohnLiu is the owner of 24, 24 and the memeber of group 
9 

Original comment by zhangyon...@gmail.com on 2 Sep 2010 at 4:52

GoogleCodeExporter commented 8 years ago
Got the following exception when call group/mygroups API. It's class cast issue.

[#|2010-09-03T10:34:12.724+0800|INFO|glassfishv3.0|javax.enterprise.system.std.c
om.sun.enterprise.v3.services.impl|_ThreadID=31;_ThreadName=http-thread-pool-808
0-(2);|Hibernate: select g.* from elgg_group_entity g, user_groups ug where (g.g
uid=ug.group_id and ug.user_id=?) or g.owner_guid=?|#]

[#|2010-09-03T10:34:14.094+0800|INFO|glassfishv3.0|javax.enterprise.system.std.c
om.sun.enterprise.v3.services.impl|_ThreadID=31;_ThreadName=http-thread-pool-808
0-(2);|Hibernate: select elgguserse0_.guid as guid8_0_, elgguserse0_.banned as b
anned8_0_, elgguserse0_.code as code8_0_, elgguserse0_.email as email8_0_, elggu
serse0_.language as language8_0_, elgguserse0_.last_action as last6_8_0_, elggus
erse0_.last_login as last7_8_0_, elgguserse0_.latitude as latitude8_0_, elgguser
se0_.login_time as login9_8_0_, elgguserse0_.longitude as longitude8_0_, elgguse
rse0_.name as name8_0_, elgguserse0_.password as password8_0_, elgguserse0_.prev
_last_action as prev13_8_0_, elgguserse0_.prev_last_login as prev14_8_0_, elggus
erse0_.salt as salt8_0_, elgguserse0_.username as username8_0_ from elgg_users_e
ntity elgguserse0_ where elgguserse0_.guid=?|#]

[#|2010-09-03T10:35:24.624+0800|INFO|glassfishv3.0|javax.enterprise.system.std.c
om.sun.enterprise.v3.services.impl|_ThreadID=31;_ThreadName=http-thread-pool-808
0-(2);|Hibernate: select count(*) from user_groups where group_id = ?|#]

[#|2010-09-03T10:35:25.327+0800|SEVERE|glassfishv3.0|com.sun.jersey.server.impl.
application.WebApplicationImpl|_ThreadID=31;_ThreadName=http-thread-pool-8080-(2
);|The RuntimeException could not be mapped to a response, re-throwing to the HT
TP container
java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.I
nteger
        at prototype.socialrays.group.persistence.GroupDaoImpl$7.doInHibernate(G
roupDaoImpl.java:295)
        at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(Hibern
ateTemplate.java:406)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(Hibernat
eTemplate.java:339)
        at prototype.socialrays.group.persistence.GroupDaoImpl.getGroupSize(Grou
pDaoImpl.java:291)
        at prototype.socialrays.group.service.GroupServiceImpl.listUserGroups(Gr
oupServiceImpl.java:88)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflecti
on(AopUtils.java:307)

Original comment by xianhao.lv@gmail.com on 3 Sep 2010 at 2:48

GoogleCodeExporter commented 8 years ago
The root cause for this class cast exception is caused by the return type of 
"select count(*)..." In some case, hibernate returns an Integer type, some case 
Long type, and some case BigInteger type. 

Should be fixed now. Please verify.

Original comment by zhangyon...@gmail.com on 3 Sep 2010 at 5:45

GoogleCodeExporter commented 8 years ago
I created a user, then created 3 groups for the user. but API group/mygroups 
returned 21 groups for the user. Every group has 6 repeated groups. 

{"list":[
{"closed":"false","description":"Xianhaogroup3","groupType":"PRIVATE","guid":"49
","name":"xianhaogroup3","owner":{"banned":"no","code":"3333","email":"59093558@
qq.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime
":"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3e
fa157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sa
lt":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"}
,
{"closed":"false","description":"Xianhaogroup3","groupType":"PRIVATE","guid":"49
","name":"xianhaogroup3","owner":{"banned":"no","code":"3333","email":"59093558@
qq.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime
":"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3e
fa157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sa
lt":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"}
,
{"closed":"false","description":"Xianhaogroup3","groupType":"PRIVATE","guid":"49
","name":"xianhaogroup3","owner":{"banned":"no","code":"3333","email":"59093558@
qq.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime
":"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3e
fa157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sa
lt":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"}
,
{"closed":"false","description":"Xianhaogroup3","groupType":"PRIVATE","guid":"49
","name":"xianhaogroup3","owner":{"banned":"no","code":"3333","email":"59093558@
qq.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime
":"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3e
fa157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sa
lt":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"}
,
{"closed":"false","description":"Xianhaogroup3","groupType":"PRIVATE","guid":"49
","name":"xianhaogroup3","owner":{"banned":"no","code":"3333","email":"59093558@
qq.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime
":"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3e
fa157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sa
lt":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"}
,
{"closed":"false","description":"Xianhaogroup3","groupType":"PRIVATE","guid":"49
","name":"xianhaogroup3","owner":{"banned":"no","code":"3333","email":"59093558@
qq.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime
":"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3e
fa157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sa
lt":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"}
,
{"closed":"false","description":"Xianhaogroup3","groupType":"PRIVATE","guid":"49
","name":"xianhaogroup3","owner":{"banned":"no","code":"3333","email":"59093558@
qq.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime
":"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3e
fa157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sa
lt":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"}
,
{"closed":"false","description":"Xianhaogroup2","groupType":"PUBLIC","guid":"48"
,"name":"xianhaogroup2","owner":{"banned":"no","code":"3333","email":"59093558@q
q.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime"
:"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3ef
a157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sal
t":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"},
{"closed":"false","description":"Xianhaogroup2","groupType":"PUBLIC","guid":"48"
,"name":"xianhaogroup2","owner":{"banned":"no","code":"3333","email":"59093558@q
q.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime"
:"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3ef
a157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sal
t":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"},
{"closed":"false","description":"Xianhaogroup2","groupType":"PUBLIC","guid":"48"
,"name":"xianhaogroup2","owner":{"banned":"no","code":"3333","email":"59093558@q
q.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime"
:"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3ef
a157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sal
t":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"},
{"closed":"false","description":"Xianhaogroup2","groupType":"PUBLIC","guid":"48"
,"name":"xianhaogroup2","owner":{"banned":"no","code":"3333","email":"59093558@q
q.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime"
:"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3ef
a157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sal
t":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"},
{"closed":"false","description":"Xianhaogroup2","groupType":"PUBLIC","guid":"48"
,"name":"xianhaogroup2","owner":{"banned":"no","code":"3333","email":"59093558@q
q.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime"
:"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3ef
a157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sal
t":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"},
{"closed":"false","description":"Xianhaogroup2","groupType":"PUBLIC","guid":"48"
,"name":"xianhaogroup2","owner":{"banned":"no","code":"3333","email":"59093558@q
q.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime"
:"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3ef
a157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sal
t":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"},
{"closed":"false","description":"Xianhaogroup2","groupType":"PUBLIC","guid":"48"
,"name":"xianhaogroup2","owner":{"banned":"no","code":"3333","email":"59093558@q
q.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime"
:"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3ef
a157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sal
t":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"},
{"closed":"false","description":"Xianhaogroup1","groupType":"PUBLIC","guid":"47"
,"name":"xianhaogroup1","owner":{"banned":"no","code":"3333","email":"59093558@q
q.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime"
:"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3ef
a157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sal
t":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"},
{"closed":"false","description":"Xianhaogroup1","groupType":"PUBLIC","guid":"47"
,"name":"xianhaogroup1","owner":{"banned":"no","code":"3333","email":"59093558@q
q.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime"
:"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3ef
a157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sal
t":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"},
{"closed":"false","description":"Xianhaogroup1","groupType":"PUBLIC","guid":"47"
,"name":"xianhaogroup1","owner":{"banned":"no","code":"3333","email":"59093558@q
q.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime"
:"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3ef
a157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sal
t":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"},
{"closed":"false","description":"Xianhaogroup1","groupType":"PUBLIC","guid":"47"
,"name":"xianhaogroup1","owner":{"banned":"no","code":"3333","email":"59093558@q
q.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime"
:"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3ef
a157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sal
t":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"},
{"closed":"false","description":"Xianhaogroup1","groupType":"PUBLIC","guid":"47"
,"name":"xianhaogroup1","owner":{"banned":"no","code":"3333","email":"59093558@q
q.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime"
:"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3ef
a157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sal
t":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"},
{"closed":"false","description":"Xianhaogroup1","groupType":"PUBLIC","guid":"47"
,"name":"xianhaogroup1","owner":{"banned":"no","code":"3333","email":"59093558@q
q.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime"
:"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3ef
a157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sal
t":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"},
{"closed":"false","description":"Xianhaogroup1","groupType":"PUBLIC","guid":"47"
,"name":"xianhaogroup1","owner":{"banned":"no","code":"3333","email":"59093558@q
q.com","guid":"937","language":"en","lastAction":"0","lastLogin":"0","loginTime"
:"2010-09-04T12:20:59+08:00","name":"xianhao","password":"c27d52af8025e38e67d3ef
a157681cb5","passwordValid":"true","prevLastAction":"0","prevLastLogin":"0","sal
t":"b57d3ab4","userValid":"true","username":"xianhao"},"siteId":"0","size":"0"}
]}

Original comment by xianhao.lv@gmail.com on 4 Sep 2010 at 6:25

GoogleCodeExporter commented 8 years ago
This issue was updated by revision r91.

Changed SQL to remove the duplicated records.

Original comment by zhangyon...@gmail.com on 6 Sep 2010 at 3:28

GoogleCodeExporter commented 8 years ago
Test issue in Comment 8 from android side. works well, verified. 

Original comment by xianhao.lv@gmail.com on 6 Sep 2010 at 5:51