src/Biz/User/Register/Impl/BinderRegistDecoderImpl.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace Biz\User\Register\Impl;

use Biz\System\SettingException;

class BinderRegistDecoderImpl extends RegistDecoder
{
    protected function validateBeforeSave($registration)
    {
        $type = $registration['type'];

        $thirdLoginInfo = $this->getSettingService()->get('login_bind', array());
        if (empty($thirdLoginInfo["{$type}_enabled"]) ||
                empty($thirdLoginInfo["{$type}_key"]) ||
                empty($thirdLoginInfo["{$type}_secret"])) {
            throw SettingException::OAUTH_CLIENT_TYPE_INVALID();
        }
    }

    protected function dealDataBeforeSave($registration, $user)
    {
        if (!empty($registration['password'])) {
            $user['salt'] = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
            $user['password'] = $this->getPasswordEncoder()->encodePassword($registration['password'], $user['salt']);
        } else {
            $user['salt'] = '';
            $user['password'] = '';
        }

        if (in_array($registration['type'], array('weixinmob', 'weixinweb'))) {
            $user['type'] = 'weixin';
        }

        return $user;
    }

    protected function dealDataAfterSave($registration, $user)
    {
        $this->getUserService()->bindUser(
            $registration['type'],
            $registration['authid'],
            $user['id'],
            array()
        );
    }

    /**
     * return \Biz\System\Service\SettingService
     */
    protected function getSettingService()
    {
        return $this->biz->service('System:SettingService');
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。