Skip to content

Commit

Permalink
fixed api token session and add some hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
yushine committed Jan 24, 2025
1 parent e3e95fb commit 2f40e7a
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 8 deletions.
3 changes: 1 addition & 2 deletions innopacks/common/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

use Barryvdh\Debugbar\Facades\Debugbar;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\DB;
Expand Down Expand Up @@ -1041,7 +1040,7 @@ function to_sql(mixed $builder): string
*/
function seller_enabled(): bool
{
return class_exists(\InnoShop\Seller\SellerServiceProvider::class);
return class_exists(\InnoShop\Seller\SellerServiceProvider::class) && env('SELLER_ENABLED', true);
}
}

Expand Down
4 changes: 3 additions & 1 deletion innopacks/common/src/Repositories/CustomerRepo.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function create($data): Customer
$item = new Customer($data);
$item->saveOrFail();

return $item;
return fire_hook_filter('repo.customer.create', $item);
}

/**
Expand All @@ -131,6 +131,8 @@ public function update($item, $data): mixed
$item->fill($data);
$item->saveOrFail();

fire_hook_filter('repo.customer.update', $item);

return $item;
}

Expand Down
2 changes: 1 addition & 1 deletion innopacks/common/src/Repositories/Order/ItemRepo.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private function handleItem(Order $order, $requestData): array
'product_id' => $sku->product_id,
'order_number' => $order->number,
'product_sku' => $sku->code,
'variant_label' => $requestData['variant_label'],
'variant_label' => $requestData['variant_label'] ?? $sku->variant_label,
'name' => $requestData['product_name'],
'image' => $requestData['image'],
'quantity' => $requestData['quantity'],
Expand Down
3 changes: 1 addition & 2 deletions innopacks/common/src/Services/CartService.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,8 @@ public function handleResponse(): array
'amount_format' => currency_format($selectedAmount),
'list' => CartListItem::collection($allCartItems)->jsonSerialize(),
];
$data = fire_hook_filter('service.cart.response', $data);

return $data;
return fire_hook_filter('service.cart.response', $data);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions innopacks/front/resources/views/layouts/header.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
</div>
</div>
@endif
@hookinsert('layouts.header.currency.after')
</div>
<div class="top-info">
@hookinsert('layouts.header.news.before')
<a href="{{ front_route('articles.index') }}">News</a>
@hookupdate('layouts.header.telephone')
<span><i class="bi bi-telephone-outbound"></i> {{ system_setting('telephone') }}</span>
Expand Down
1 change: 1 addition & 0 deletions innopacks/panel/resources/views/customers/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

<x-common-form-select title="用户组" name="customer_group_id" :options="$groups" key="id" label="name"
value="{{ old('customer_group_id', $customer->customer_group_id) }}"/>
@hookinsert('panel.customer.form.group.after')

<x-common-form-select title="语言" name="locale" :options="$locales" key="code" label="name"
value="{{ old('locale', $customer->locale) }}"/>
Expand Down
2 changes: 1 addition & 1 deletion innopacks/panel/resources/views/customers/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</td>
<td>
<div class="d-flex gap-1">
<a href="{{ panel_route('customers.login', [$item->id]) }}">
<a href="{{ panel_route('customers.login', [$item->id]) }}" target="_blank">
<el-button size="small" plain type="primary">{{ __('panel/customer.login_frontend')}}</el-button>
</a>
<a href="{{ panel_route('customers.edit', [$item->id]) }}">
Expand Down
1 change: 1 addition & 0 deletions innopacks/panel/src/Controllers/CustomerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public function destroy(Customer $customer): RedirectResponse
*/
public function loginFrontend(Customer $customer): mixed
{
session()->forget('front_api_token');
auth()->guard('customer')->loginUsingId($customer->id);

return redirect(account_route('index'));
Expand Down
2 changes: 1 addition & 1 deletion innopacks/plugin/resources/views/plugins/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
:placeholder="$field['placeholder'] ?? ''"
:description="$field['description'] ?? ''"
:error="$errors->first($field['name'])"
:required="(bool)$field['required']"
:required="(bool)($field['required'] ?? false)"
:value="old($field['name'], $field['value'] ?? '')" />
@endif

Expand Down

0 comments on commit 2f40e7a

Please sign in to comment.