1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 04:01:31 +08:00
koogua cbc2e5762a !11 阶段性合并
* 根据app需要作出相应调整
* 路由增加命名name,增加app应用管理
* 完成基本API,增加h5和小程序支付定义
2020-11-10 10:25:16 +08:00

71 lines
1.4 KiB
PHP

<?php
namespace App\Http\Home\Services;
use App\Repos\User as UserRepo;
use App\Services\Auth\Home as AuthService;
use App\Services\Logic\Account\Register as RegisterService;
use App\Validators\Account as AccountValidator;
use App\Validators\Captcha as CaptchaValidator;
class Account extends Service
{
/**
* @var AuthService
*/
protected $auth;
public function __construct()
{
$this->auth = $this->getDI()->get('auth');
}
public function register()
{
$service = new RegisterService();
$account = $service->handle();
$userRepo = new UserRepo();
$user = $userRepo->findById($account->id);
$this->auth->saveAuthInfo($user);
return $user;
}
public function loginByPassword()
{
$post = $this->request->getPost();
$validator = new AccountValidator();
$user = $validator->checkUserLogin($post['account'], $post['password']);
$validator = new CaptchaValidator();
$validator->checkCode($post['ticket'], $post['rand']);
$this->auth->saveAuthInfo($user);
}
public function loginByVerify()
{
$post = $this->request->getPost();
$validator = new AccountValidator();
$user = $validator->checkVerifyLogin($post['account'], $post['verify_code']);
$this->auth->saveAuthInfo($user);
}
public function logout()
{
$this->auth->clearAuthInfo();
}
}