Joomla3 二次开发 增加discuz的登陆验证方式

这个与密码验证相关的文件的位置是 (注意是Joomla3.x 其它版本暂时没研究) :

JOOMLA/plugins/authentication/joomla/joomla.php 

首先要把discuz的ucenter_members表的数据 导入到 Joomla的users表 具体的自己做吧

关于密码的格式 我的处理方式是把 discuz的拼凑成 Joomla那种字符串的 :

$uc$/password/salt

这种样式 其中password跟salt都是discuz的数据

Joomla关于会员信息的表只有两张 一个users 还有一个user_usergroup_map(暂时不管)

所以导入时候 只要把ucenter_members改造一下就好了 自行导入到joomla的users表吧

要修改的部分是

        // Get a database object
        $db    = JFactory::getDbo();
        $query = $db->getQuery(true)
            ->select('id, password')
            ->from('#__users')
            ->where('username=' . $db->quote($credentials['username']));

        $db->setQuery($query);
        $result = $db->loadObject();

后面开始

            //导出discuz会员表 ucenter 关于discuz的password跟salt处理方式是
            //组合成为 $uc$/password/salt 后面通过'/'切割 方便使用discuz的公式验证密码
            if( substr( $result->password, 0 , 4) == '$uc$')
            {
                // discuz具体的验证方法是 $saltpassword = md5( md5( $plaintext_password ) . $salt);
                $str = explode( '/',  $result->password);
                $match = md5( md5( $credentials['password']) . $str[2]) === $str[1] ? true : false;
                
            }
            else if (substr($result->password, 0, 4) == '$2y$')
            {
                // BCrypt passwords are always 60 characters, but it is possible that salt is appended although non standard.
                $password60 = substr($result->password, 0, 60);

                if (JCrypt::hasStrongPasswordSupport())
                {
                    $match = password_verify($credentials['password'], $password60);
                }
            }
            elseif (substr($result->password, 0, 8) == '{SHA256}')
            {
                // Check the password
                $parts    = explode(':', $result->password);
                var_dump( $parts);
                $crypt    = $parts[0];
                $salt    = @$parts[1];
                $testcrypt = JUserHelper::getCryptedPassword($credentials['password'], $salt, 'sha256', false);

                if ($result->password == $testcrypt)
                {
                    $match = true;
                }
            }
            else
            {
                // Check the password
                $parts    = explode(':', $result->password);
                var_dump( $parts);
                $crypt    = $parts[0];
                $salt    = @$parts[1];

                $testcrypt = JUserHelper::getCryptedPassword($credentials['password'], $salt, 'md5-hex', false);

                if ($crypt == $testcrypt)
                {
                    $match = true;
                }
            }

这样应该差不多了,我继续研究看看还有什么要做的。初次学习joomla ,多多指教。


补充 还有创建分组的数据 表名叫 user_usergroup_map

在这里创建 user 跟 group 关联的数据 否则是无法登陆的。


转载于:https://my.oschina.net/imot/blog/188281

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值