mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-28 05:11:39 +08:00
42 lines
992 B
PHP
42 lines
992 B
PHP
<?php
|
|
|
|
namespace App\Services\Frontend\Account;
|
|
|
|
use App\Models\Account as AccountModel;
|
|
use App\Repos\User as UserRepo;
|
|
use App\Services\Frontend\Service as FrontendService;
|
|
use App\Validators\Account as AccountValidator;
|
|
use App\Validators\Verify as VerifyValidator;
|
|
|
|
class RegisterByEmail extends FrontendService
|
|
{
|
|
|
|
public function handle()
|
|
{
|
|
$post = $this->request->getPost();
|
|
|
|
$verifyValidator = new VerifyValidator();
|
|
|
|
$verifyValidator->checkEmailCode($post['email'], $post['verify_code']);
|
|
|
|
$accountValidator = new AccountValidator();
|
|
|
|
$data = [];
|
|
|
|
$data['email'] = $accountValidator->checkEmail($post['email']);
|
|
|
|
$accountValidator->checkIfEmailTaken($post['email']);
|
|
|
|
$data['password'] = $accountValidator->checkPassword($post['password']);
|
|
|
|
$account = new AccountModel();
|
|
|
|
$account->create($data);
|
|
|
|
$userRepo = new UserRepo();
|
|
|
|
return $userRepo->findById($account->id);
|
|
}
|
|
|
|
}
|