src/Biz/User/Service/Impl/AuthServiceImpl.php
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Biz\User\Service\Impl;
use Biz\BaseService;
use Biz\Sensitive\SensitiveException;
use Biz\User\Service\AuthService;
use Codeages\RateLimiter\RateLimiter;
use AppBundle\Common\SimpleValidator;
use AppBundle\Common\TimeMachine;
use Topxia\Service\Common\ServiceKernel;
use Biz\User\UserException;
class AuthServiceImpl extends BaseService implements AuthService
{
const MID_IP_MAX_ALLOW_ATTEMPT_ONE_DAY = 30;
const HIGH_IP_MAX_ALLOW_ATTEMPT_ONE_DAY = 10;
const HIGH_IP_MAX_ALLOW_ATTEMPT_ONE_HOUR = 1;
private $partner = null;
public function register($registration, $type = 'default')
{
if (isset($registration['nickname']) && !empty($registration['nickname'])
&& $this->getSensitiveService()->scanText($registration['nickname'])) {
$this->createNewException(SensitiveException::FORBIDDEN_WORDS());
}
//营销平台不需要注册频率限制
if (!$this->isMarketingType($registration) && $this->registerLimitValidator($registration)) {
$this->createNewException(UserException::FORBIDDEN_REGISTER_LIMIT());
}
//FIXME 应该调用GeneralDaoImpl里的事务
$this->getKernel()->getConnection()->beginTransaction();
try {
$registration = $this->refillFormData($registration, $type);
$registration['providerType'] = $this->getAuthProvider()->getProviderName();
$newUser = $this->getUserService()->register(
$registration,
$this->biz['user.register.type.toolkit']->getRegisterTypes($registration)
);
$this->getKernel()->getConnection()->commit();
return $newUser;
} catch (\Exception $e) {
$this->getKernel()->getConnection()->rollBack();
throw $e;
}
}
protected function registerLimitValidator($registration)
{
$authSettings = $this->getSettingService()->get('auth', array());
$user = $this->getCurrentUser();
if (!$user->isAdmin() && isset($authSettings['register_protective'])) {
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。