41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Auth;
|
|
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
use App\Services\Auth\GoogleService as Service;
|
|
use App\Entities\UserEntity as Entity;
|
|
|
|
class GoogleController extends AuthController
|
|
{
|
|
private ?Service $_service = null;
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
$this->uri_path .= strtolower($this->getService()->getClassName()) . '/';
|
|
$this->class_path = $this->getService()->getClassPath();
|
|
$this->title = lang("{$this->getService()->getClassPath()}.title");;
|
|
}
|
|
|
|
final public function getService(): Service
|
|
{
|
|
if (!$this->_service) {
|
|
$this->_service = new Service($this->getSocket(), $this->request);
|
|
}
|
|
return $this->_service;
|
|
}
|
|
|
|
//로그인처리
|
|
protected function login_process(): Entity
|
|
{
|
|
$access_code = $this->request->getVar('code');
|
|
if (!$access_code) {
|
|
throw new \Exception("구글 로그인 실패");
|
|
}
|
|
return $this->getService()->login($this->getService()->checkUser($access_code));
|
|
}
|
|
}
|