Pārlūkot izejas kodu

認証ないアクセスの場合でも顧客スイッチが必要なケースをフォロー

develop
sosuke.iwabuchi pirms 1 gada
vecāks
revīzija
801626e745
5 mainītis faili ar 20 papildinājumiem un 5 dzēšanām
  1. +1
    -0
      app/Http/Controllers/Web/QRService/Acquisition/GetAcquisitionTokenController.php
  2. +3
    -1
      app/Http/Controllers/Web/QRService/CreateTicketController.php
  3. +3
    -0
      app/Http/Controllers/Web/QRService/CreateTicketParam.php
  4. +1
    -1
      app/Http/Controllers/Web/WebController.php
  5. +12
    -3
      app/Sessions/SessionUser.php

+ 1
- 0
app/Http/Controllers/Web/QRService/Acquisition/GetAcquisitionTokenController.php Parādīt failu

@@ -43,6 +43,7 @@ class GetAcquisitionTokenController extends WebController

$res = [
"token" => $token->token,
"customer_id" => $this->sessionUser->customerId(),
];

return $this->successResponse($res);


+ 3
- 1
app/Http/Controllers/Web/QRService/CreateTicketController.php Parādīt failu

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Web\QRService;
use App\Http\Controllers\Web\WebController;
use App\Logics\QRService\CreateLogic;
use App\Logics\QRService\QRCryptoLogic;
use App\Models\HtpmsCustomer\HtpmsCustomerConnectionSwitch;
use App\Models\HtpmsCustomer\QRService\AcquisitionTicket;
use App\Models\HtpmsCustomer\QRService\AcquisitionTicketToken;
use Illuminate\Http\JsonResponse;
@@ -33,8 +34,9 @@ class CreateTicketController extends WebController
{
$param = $this->param;

$token = AcquisitionTicketToken::whereToken($param->token)->first();
$token = AcquisitionTicketToken::whereToken($param->token)->first();
if ($token === null) {
logger(sprintf("トークン無 (%d) %s", $param->customerId, $param->token));
return $this->failedResponse();
}



+ 3
- 0
app/Http/Controllers/Web/QRService/CreateTicketParam.php Parādīt failu

@@ -3,8 +3,10 @@
namespace App\Http\Controllers\Web\QRService;

use App\Http\Controllers\Web\BaseParam;
use App\Models\ColumnName;

/**
* @property int $customerId
* @property string $token
* @property string|null $ticketId
*/
@@ -13,6 +15,7 @@ class CreateTicketParam extends BaseParam
public function rules(): array
{
return [
'customer_id' => $this->numeric(),
'token' => $this->str(),
'ticket_id' => $this->str(true),
];


+ 1
- 1
app/Http/Controllers/Web/WebController.php Parādīt failu

@@ -173,7 +173,7 @@ abstract class WebController extends BaseController
$this->validated = $validator->validated();
$this->getParam()->setData($this->validated);

$this->sessionUser->init();
$this->sessionUser->init($this->validated);

$this->transaction->beginTransaction();
$ret = $this->run($request);


+ 12
- 3
app/Sessions/SessionUser.php Parādīt failu

@@ -22,23 +22,26 @@ class SessionUser
private bool $isSwtiched = false;
private bool $isInit = false;

public function init()
public function init(array $param = [])
{
if ($this->isInit === true) {
return;
}
$this->initSessionUser();
$this->initSessionUser($param);
$this->isInit = true;
}
private function initSessionUser()
private function initSessionUser(array $param)
{
// 認証していない場合はスキップ
$this->user = Auth::user();

if ($this->user instanceof User && $this->user->customer_id) {
HtpmsCustomerConnectionSwitch::switch($this->user->customer_id);
} else if (!!data_get($param, "customer_id")) {
HtpmsCustomerConnectionSwitch::switch(data_get($param, "customer_id"));
}


$user = Auth::user();
$ckeck = Auth::check();
if ($this->user === null) {
@@ -123,6 +126,12 @@ class SessionUser
if ($this->user->customer_code === null) throw new LogicException();
return $this->user->customer_code;
}
public function customerId(): int
{
if ($this->user === null) throw new LogicException();
if ($this->user->customer_id === null) throw new LogicException();
return $this->user->customer_id;
}

private function getStoreKey(string $key): string
{


Notiek ielāde…
Atcelt
Saglabāt