• discuz UCenter对接遇到问题总汇


    1、登录用户需激活问题 discuz/api/uc.php

      /***
    * 激活功能
    */
    function synlogin($get, $post) {
    global $_G;

    if(!API_SYNLOGIN) {
    return API_RETURN_FORBIDDEN;
    }

    header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');

    $cookietime = 31536000;
    $uid = intval($get['uid']);
    $query = DB::query("SELECT uid, username, password FROM ".DB::table('common_member')." WHERE uid='$uid'");
    if($member = DB::fetch($query)) {
    dsetcookie('auth', authcode("$member[password]\t$member[uid]", 'ENCODE'), $cookietime);
    }else{
    //用户不存在 从UC里取用户
    $username = $get['username'];
    $query = DB::query("SELECT uid,username,password,email FROM ".DB::table('ucenter_members')." WHERE username='$username'");
    $member = DB::fetch($query);
    $password = $member['password'];
    $email = $member['email'];
    $ip = $_SERVER['REMOTE_ADDR'];
    $time = time();
    $userdata = array(
    'uid' => $uid,
    'username' => $username,
    'password' => $password,
    'email' => $email,
    'adminid' => 0,
    'groupid' => 10,
    'regdate' => $time,
    'credits' => 0,
    'timeoffset' => 9999
    );
    DB::insert('common_member', $userdata);

    $status_data = array(
    'uid' => $uid,
    'regip' => $ip,
    'lastip' => $ip,
    'lastvisit' => $time,
    'lastactivity' => $time,
    'lastpost' => 0,
    'lastsendmail' => 0,
    );
    DB::insert('common_member_status', $status_data);
    DB::insert('common_member_profile', array('uid' => $uid));
    DB::insert('common_member_field_forum', array('uid' => $uid));
    DB::insert('common_member_field_home', array('uid' => $uid));
    DB::insert('common_member_count', array('uid' => $uid));
    DB::query("UPDATE ".DB::table('common_setting')." SET svalue='$username' WHERE skey='lastmember'");

    $query = DB::query("SELECT uid, username, password FROM ".DB::table('common_member')." WHERE uid='$uid'");
    if($member = DB::fetch($query)) {
    dsetcookie('auth', authcode("$member[password]\t$member[uid]", 'ENCODE'), $cookietime);
    }
    }
    }

    问题原因:与UCenter用户对接,网站用户首次登录论坛,需要先注册用户到UCenter,api写入数据至Ucenter用户表,数据没有立即发送到discuz用户表,当请求discuz登录时,discuz会要求激话,而导致直接登录失败。解决方式:在用户请求登录时(synlogin),用户不在了,则请求ucenter用户表查询用户,再写入到discuz

    2、修改密码能及时同步问题

          discuz修改密码后将修改密码和email的信息通过ucclient传递给ucenter,ucenter在收到消息后将消息存入cdb_uc_notelist表,而后从cdb_uc_notelist取出一条close为0的记录,逐一向各个应用发送修改密码的通知。当用户登录ucenter才会向应用发送指令,

    解决方法:

    uc_client\client.php文件中的

    function uc_user_edit($username, $oldpw, $newpw, $email, $ignoreoldpw = 0, $questionid = '', $answer = '') {
    return call_user_func(UC_API_FUNC, 'user', 'edit', array('username'=>$username, 'oldpw'=>$oldpw, 'newpw'=>$newpw, 'email'=>$email, 'ignoreoldpw'=>$ignoreoldpw, 'questionid'=>$questionid, 'answer'=>$answer));
    }

    //改为

    function uc_user_edit($username, $oldpw, $newpw, $email, $ignoreoldpw = 0, $questionid = '', $answer = '') {
    return call_user_func('uc_api_post', 'user', 'edit', array('username'=>$username, 'oldpw'=>$oldpw, 'newpw'=>$newpw, 'email'=>$email, 'ignoreoldpw'=>$ignoreoldpw, 'questionid'=>$questionid, 'answer'=>$answer));
    }


    uc_server\control\user.php文件中的 onedit()方法中的

    01.$_ENV['note']->add('updatepw', 'username='.urlencode($username).'&password=');
    //改为

    $_ENV['note']->add('updatepw', 'username='.urlencode($username).'&password='.urlencode($newpw).'&email='.urlencode($email));

    uc_server\model\note.php文件中的send()方法中注释如下两行:

    $closenote = FALSE;
    break;


     

  • 相关阅读:
    缩减apk大小
    android 的安全问题
    android listview 优化
    Python正则表达式指南
    程序员必须知道的几个国外IT网站
    去掉配置项,开发自信的软件
    去掉配置项,开发自信的软件
    Linux防火墙设置
    Linux防火墙设置
    linux下如何使用sftp命令进行文件上传和下载
  • 原文地址:https://www.cnblogs.com/linyu/p/2303237.html
Copyright © 2020-2023  润新知