mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-23 03:50:56 +08:00
46 lines
840 B
PHP
46 lines
840 B
PHP
<?php
|
|
|
|
namespace App\Http\Home\Services;
|
|
|
|
use App\Models\User as UserModel;
|
|
use App\Validators\Validator as AppValidator;
|
|
use Phalcon\Mvc\User\Component;
|
|
|
|
class Service extends Component
|
|
{
|
|
|
|
public function getCurrentUser()
|
|
{
|
|
$authUser = $this->getAuthUser();
|
|
|
|
if ($authUser) {
|
|
$user = UserModel::findFirst($authUser->id);
|
|
} else {
|
|
$user = new UserModel();
|
|
}
|
|
|
|
return $user;
|
|
}
|
|
|
|
public function getLoginUser()
|
|
{
|
|
$authUser = $this->getAuthUser();
|
|
|
|
$validator = new AppValidator();
|
|
|
|
$validator->checkAuthUser($authUser);
|
|
|
|
$user = UserModel::findFirst($authUser->id);
|
|
|
|
return $user;
|
|
}
|
|
|
|
public function getAuthUser()
|
|
{
|
|
$auth = $this->getDI()->get('auth');
|
|
|
|
return $auth->getAuthInfo();
|
|
}
|
|
|
|
}
|