1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-28 05:11:39 +08:00
xiaochong0302 cf5e50f402 增加第三方登录设计
整理代码
2020-04-16 19:29:09 +08:00

45 lines
1.0 KiB
PHP

<?php
namespace App\Services\Frontend\Account;
use App\Repos\Account as AccountRepo;
use App\Services\Frontend\Service;
use App\Validators\Account as AccountValidator;
use App\Validators\Security as SecurityValidator;
class EmailUpdate extends Service
{
public function updateEmail()
{
$post = $this->request->getPost();
$user = $this->getLoginUser();
$accountRepo = new AccountRepo();
$account = $accountRepo->findById($user->id);
$accountValidator = new AccountValidator();
$email = $accountValidator->checkEmail($post['email']);
if ($email != $account->email) {
$accountValidator->checkIfEmailTaken($post['email']);
}
$accountValidator->checkOriginPassword($account, $post['origin_password']);
$securityValidator = new SecurityValidator();
$securityValidator->checkVerifyCode($post['email'], $post['verify_code']);
$account->email = $email;
$account->update();
return $account;
}
}