UCenter原理

1、用户登录discuz,通过logging.php文件中的函数uc_user_login对post过来的数据进行验证,也就是对username和password进行验证。

2、如果验证成功,将调用位于uc_client下client.php文件中的函数uc_user_synlogin,在这个函数中调用 uc_api_post('user', 'synlogin', array('uid'=>$uid))。

3、然后这个函数后向Ucenter的index.php传递数据,index.php接受传递的数据,获得model为user,action为synlogin的值。

4、然后Ucenter的index.php调用control目录下的user.php类中的onsynlogin方法,通过foreach循环,以javascript的方式通知uc应用列表中开启同步登陆的应用进行同步登录;即通过get方式传递给各个应用目录中api下的uc.php一些数据。

5、uc.php接收通知并处理get过来的数据,并在函数synlogin(位于uc.php中)通过函数_authcode加密数据(默认以UC_KEY作为密钥),用函数_setcookie设置cookie。

6、各个应用用对应的密钥解码上面设置的cookie,得到用户id等数据;通过这个值来判断用户是否经过其它应用登录过,从而让用户可以自动登陆。


应用程序的logging.php ------>uc_client中的client.php------>Ucenter------>应用程序中api/uc.php

      其实Ucenter实现同步登陆的原理就是cookie,一个应用登陆成功之后,向Ucenter传递数据,让Ucenter通知其他的应用也设置cookie,这样用户在访问其他应用的时候通过已经设置好的cookie实现自动登陆。了解了Ucenter的同步原理,再遇到无法同步登陆,或者开发一些与UCenter接口的时候就会容易很多。

 

login:

user(ajax or jquery)->login->(fun判断)->Ucenter_Func->return to user

.continue  run ajax or jquery  ->>send list of all URL(is made up with site  which is store in the UCenter and en encoded String(action and name)) to each site

then each code which worked on different sites works ,likes java , UC,it is a servlet, it decode the url and run the code , for example ,it returns cookies

 

logout:

user(ajax or jquery)->logout->(fun判断)->Ucenter_Func->return to user

.continue  run ajax or jquery  ->>send list of all (is made up with site  which is store in the UCenter and en encoded String(action and name)) each site

then each code which worked on different sites works ,likes java , UC,it is a servlet, it decode the url and run the code , for example ,it change every cookie to maxExpire=0

 

其余都相似。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值