Compare commits
18 Commits
main
...
feature/Au
| Author | SHA1 | Date | |
|---|---|---|---|
| f072bd1ee8 | |||
| f01992368e | |||
| b32ee444ca | |||
| cee480fff5 | |||
| 5024a242d2 | |||
| 0bba710b7d | |||
| f788f9a7ea | |||
| e74619d0ab | |||
| 5b42e23afc | |||
| 51aa3b157c | |||
| b24b61c754 | |||
| 5d2501c71c | |||
| 7fb9e345a2 | |||
| 9d86e329fb | |||
| 4596025ba3 | |||
| 1dbd816da2 | |||
| 52ed10f831 | |||
| e99aa9b8f1 |
@@ -1,28 +1,36 @@
|
|||||||
FROM docker.arvancloud.ir/dunglas/frankenphp:1.11.2-php8.5-trixie
|
FROM php:8.5.3-fpm-alpine3.23
|
||||||
|
|
||||||
RUN apt-get update \
|
# Install common PHP extension dependencies
|
||||||
&& apt-get install -y --no-install-recommends libpq-dev \
|
RUN apk update && apk add --no-cache \
|
||||||
|
bash \
|
||||||
|
curl \
|
||||||
|
libpng \
|
||||||
|
libpng-dev \
|
||||||
|
libjpeg-turbo-dev \
|
||||||
|
freetype-dev \
|
||||||
|
libwebp-dev \
|
||||||
|
libxml2-dev \
|
||||||
unzip \
|
unzip \
|
||||||
zip \
|
libzip-dev \
|
||||||
&& install-php-extensions pdo_pgsql pgsql \
|
libpq-dev \
|
||||||
&& apt-get clean \
|
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& docker-php-ext-install pdo_pgsql gd zip
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
WORKDIR /var/www/payment
|
WORKDIR /var/www/payment
|
||||||
|
|
||||||
#ENV SERVER_NAME=your-domain-name.example.com
|
|
||||||
|
|
||||||
# Copy Laravel application
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Give permissions to storage and bootstrap/cache
|
RUN chmod -R 775 /var/www/payment/storage /var/www/payment/bootstrap/cache
|
||||||
RUN chmod -R 777 storage bootstrap/cache
|
|
||||||
|
|
||||||
# Install Composer
|
# Install Composer
|
||||||
COPY --from=docker.arvancloud.ir/composer:latest /usr/bin/composer /usr/bin/composer
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||||
|
|
||||||
|
# Default command
|
||||||
CMD composer install ;\
|
CMD composer install ;\
|
||||||
|
composer dump-autoload --optimize --classmap-authoritative ;\
|
||||||
php artisan key:generate ;\
|
php artisan key:generate ;\
|
||||||
php artisan migrate ;\
|
php artisan migrate ;\
|
||||||
php artisan db:seed ;\
|
php artisan db:seed ;\
|
||||||
frankenphp php-server -r public/
|
php-fpm
|
||||||
|
|||||||
@@ -14,19 +14,28 @@ COPY . .
|
|||||||
|
|
||||||
RUN composer dump-autoload --optimize --classmap-authoritative
|
RUN composer dump-autoload --optimize --classmap-authoritative
|
||||||
|
|
||||||
FROM docker.arvancloud.ir/dunglas/frankenphp:1.11.2-php8.5-trixie AS application
|
FROM php:8.5.3-fpm-alpine3.23 AS application
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apk update && apk add --no-cache \
|
||||||
&& apt-get install -y --no-install-recommends libpq-dev unzip zip \
|
bash \
|
||||||
&& install-php-extensions pdo_pgsql pgsql \
|
curl \
|
||||||
&& apt-get clean \
|
libpng \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
libpng-dev \
|
||||||
|
libjpeg-turbo-dev \
|
||||||
|
freetype-dev \
|
||||||
|
libwebp-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
unzip \
|
||||||
|
libzip-dev \
|
||||||
|
libpq-dev \
|
||||||
|
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
|
||||||
|
&& docker-php-ext-install pdo_pgsql gd zip
|
||||||
|
|
||||||
WORKDIR /var/www/payment
|
WORKDIR /var/www/payment
|
||||||
|
|
||||||
COPY --from=builder /app /var/www/payment
|
COPY --from=builder /app /var/www/payment
|
||||||
|
|
||||||
RUN chown -R www-data:www-data /var/www/payment \
|
RUN chown -R www-data:www-data /var/www/payment \
|
||||||
&& chmod -R 775 storage bootstrap/cache
|
&& chmod -R 665 storage bootstrap/cache
|
||||||
|
|
||||||
CMD ["frankenphp", "php-server", "-r", "public/"]
|
CMD ["php-fpm"]
|
||||||
|
|||||||
22
backend/app/Models/User.php
Normal file → Executable file
22
backend/app/Models/User.php
Normal file → Executable file
@@ -5,28 +5,18 @@ namespace App\Models;
|
|||||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
use Database\Factories\UserFactory;
|
use Database\Factories\UserFactory;
|
||||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||||
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
||||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Laravel\Passport\HasApiTokens;
|
||||||
|
|
||||||
#[Fillable(['name', 'email', 'password'])]
|
#[Guarded(['id'])]
|
||||||
#[Hidden(['password', 'remember_token'])]
|
#[Hidden(['password'])]
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
/** @use HasFactory<UserFactory> */
|
/** @use HasFactory<UserFactory> */
|
||||||
use HasFactory, Notifiable;
|
use HasFactory, Notifiable, HasApiTokens;
|
||||||
|
protected $guarded = ['id'];
|
||||||
/**
|
|
||||||
* Get the attributes that should be cast.
|
|
||||||
*
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
protected function casts(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'email_verified_at' => 'datetime',
|
|
||||||
'password' => 'hashed',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
5
backend/app/Providers/AppServiceProvider.php
Normal file → Executable file
5
backend/app/Providers/AppServiceProvider.php
Normal file → Executable file
@@ -3,6 +3,8 @@
|
|||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Laravel\Passport\Passport;
|
||||||
|
use Carbon\CarbonInterval;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
@@ -19,6 +21,7 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
//
|
Passport::enablePasswordGrant();
|
||||||
|
Passport::personalAccessTokensExpireIn(CarbonInterval::minutes(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
31
backend/app/Traits/ApiResponse.php
Executable file
31
backend/app/Traits/ApiResponse.php
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Traits;
|
||||||
|
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
trait ApiResponse
|
||||||
|
{
|
||||||
|
public function successResponse(mixed $data = null, string $message = null, int $statusCode = 200): JsonResponse
|
||||||
|
{
|
||||||
|
if (!is_null($data)) {
|
||||||
|
return response()->json([
|
||||||
|
'data' => $data
|
||||||
|
], $statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = $message ?? __('messages.successful');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => $message
|
||||||
|
], $statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function errorResponse(string $message, string $type = 'logical_exception', int $statusCode = 422): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json([
|
||||||
|
'type' => $type,
|
||||||
|
'message' => $message
|
||||||
|
], $statusCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
65
backend/app/User/Controller/Auth/AuthController.php
Executable file
65
backend/app/User/Controller/Auth/AuthController.php
Executable file
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Controller\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Traits\ApiResponse;
|
||||||
|
use App\User\Requests\Auth\LoginRequest;
|
||||||
|
use App\User\Requests\Auth\RegisterRequest;
|
||||||
|
use App\User\Resources\UserResource;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
|
class AuthController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function register(RegisterRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
User::query()->create([
|
||||||
|
'username' => $request->username,
|
||||||
|
'email' => $request->email,
|
||||||
|
'password' => Hash::make($request->password),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$request->session()->regenerate();
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login(LoginRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$credentials = ['password' => $request->password,];
|
||||||
|
|
||||||
|
if (filter_var($request->login, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$credentials['email'] = $request->login;
|
||||||
|
} else {
|
||||||
|
$credentials['username'] = $request->login;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Auth::attempt($credentials))
|
||||||
|
{
|
||||||
|
$request->session()->regenerate();
|
||||||
|
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
return $this->successResponse(new UserResource($user));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->errorResponse(__('messages.incorrect_or_username_password'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logout(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
Auth::logout();
|
||||||
|
|
||||||
|
$request->session()->invalidate();
|
||||||
|
|
||||||
|
$request->session()->regenerateToken();
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
56
backend/app/User/Controller/ProfileController.php
Normal file
56
backend/app/User/Controller/ProfileController.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Controller;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Traits\ApiResponse;
|
||||||
|
use App\User\Requests\Profile\ChangePasswordRequest;
|
||||||
|
use App\User\Requests\Profile\EditRequest;
|
||||||
|
use App\User\Resources\UserResource;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
|
class ProfileController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function info(): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse(new UserResource(Auth::user()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(EditRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'first_name' => $request->first_name,
|
||||||
|
'last_name' => $request->last_name,
|
||||||
|
'national_id' => $request->national_id,
|
||||||
|
'address' => $request->address,
|
||||||
|
'postal_code' => $request->postal_code,
|
||||||
|
'account_number' => $request->account_number,
|
||||||
|
'phone_number' => $request->phone_number,
|
||||||
|
'province_id' => $request->province_id,
|
||||||
|
'city_id' => $request->city_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function changePassword(ChangePasswordRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
if (! Hash::check($request->current_password, $user->password)) {
|
||||||
|
return $this->errorResponse(__('messages.incorrect_current_password'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'password' => Hash::make($request->new_password),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
29
backend/app/User/Requests/Auth/LoginRequest.php
Executable file
29
backend/app/User/Requests/Auth/LoginRequest.php
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Requests\Auth;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class LoginRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'login' => 'required|string',
|
||||||
|
'password' => 'required|string',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
30
backend/app/User/Requests/Auth/RegisterRequest.php
Executable file
30
backend/app/User/Requests/Auth/RegisterRequest.php
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Requests\Auth;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class RegisterRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'username' => 'required|unique:users,username',
|
||||||
|
'email' => 'required|email|unique:users,email',
|
||||||
|
'password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:6|confirmed:',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
30
backend/app/User/Requests/Profile/ChangePasswordRequest.php
Normal file
30
backend/app/User/Requests/Profile/ChangePasswordRequest.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Requests\Profile;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class ChangePasswordRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, ValidationRule|array|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'current_password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:6',
|
||||||
|
'new_password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:6',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
37
backend/app/User/Requests/Profile/EditRequest.php
Normal file
37
backend/app/User/Requests/Profile/EditRequest.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Requests\Profile;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class EditRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, ValidationRule|array|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'first_name' => 'required|string',
|
||||||
|
'last_name' => 'required|string',
|
||||||
|
'national_id' => 'required',
|
||||||
|
'address' => 'required',
|
||||||
|
'postal_code' => 'required',
|
||||||
|
'account_number' => 'required',
|
||||||
|
'phone_number' => 'required|regex:/^964\d{9}$/|numeric|digits:11',
|
||||||
|
'province_id' => 'required',
|
||||||
|
'city_id' => 'required',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
23
backend/app/User/Resources/UserResource.php
Executable file
23
backend/app/User/Resources/UserResource.php
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class UserResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'username' => $this->username,
|
||||||
|
'email' => $this->email,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
62
backend/app/User/Services/FIB/AuthorizationService.php
Normal file
62
backend/app/User/Services/FIB/AuthorizationService.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class AuthorizationService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
protected array $inputParameters;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.authorization.url');
|
||||||
|
$this->channelName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setInputParameters(): void
|
||||||
|
{
|
||||||
|
$this->inputParameters = [
|
||||||
|
'client_id' => config('fib.authorization.client_id'),
|
||||||
|
'client_secret' => config('fib.authorization.client_secret'),
|
||||||
|
'grant_type' => 'client_credentials',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function run(): array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->sendRequest();
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Log::channel($this->channelName)
|
||||||
|
->error(get_class($this),
|
||||||
|
[
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ConnectionException
|
||||||
|
*/
|
||||||
|
public function sendRequest(): array
|
||||||
|
{
|
||||||
|
return Http::withHeaders(['Content-Type' => 'application/json'])
|
||||||
|
->throw()
|
||||||
|
->withoutVerifying()
|
||||||
|
->post($this->url, $this->inputParameters)
|
||||||
|
->json();
|
||||||
|
}
|
||||||
|
}
|
||||||
62
backend/app/User/Services/FIB/CancelPaymentService.php
Normal file
62
backend/app/User/Services/FIB/CancelPaymentService.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class CancelPaymentService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
protected string $accessToken;
|
||||||
|
protected array $headers;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.cancelPayment.url');
|
||||||
|
$this->channelName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHeaders(): void
|
||||||
|
{
|
||||||
|
$this->headers = [
|
||||||
|
'Authorization' => 'Bearer ' . $this->accessToken,
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function run(): array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->sendRequest();
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Log::channel($this->channelName)
|
||||||
|
->error(get_class($this),
|
||||||
|
[
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ConnectionException
|
||||||
|
*/
|
||||||
|
public function sendRequest(): array
|
||||||
|
{
|
||||||
|
return Http::withHeaders($this->headers)
|
||||||
|
->throw()
|
||||||
|
->withoutVerifying()
|
||||||
|
->post($this->url)
|
||||||
|
->json();
|
||||||
|
}
|
||||||
|
}
|
||||||
51
backend/app/User/Services/FIB/CheckPaymentStatusService.php
Normal file
51
backend/app/User/Services/FIB/CheckPaymentStatusService.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class CheckPaymentStatusService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.checkPaymentStatus.url');
|
||||||
|
$this->channelName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function run(): array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->sendRequest();
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Log::channel($this->channelName)
|
||||||
|
->error(get_class($this),
|
||||||
|
[
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ConnectionException
|
||||||
|
*/
|
||||||
|
public function sendRequest(): array
|
||||||
|
{
|
||||||
|
return Http::throw()
|
||||||
|
->withoutVerifying()
|
||||||
|
->post($this->url)
|
||||||
|
->json();
|
||||||
|
}
|
||||||
|
}
|
||||||
73
backend/app/User/Services/FIB/CreatePaymentService.php
Normal file
73
backend/app/User/Services/FIB/CreatePaymentService.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class CreatePaymentService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
protected string $accessToken;
|
||||||
|
protected array $headers;
|
||||||
|
protected array $inputParameters;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.createPayment.url');
|
||||||
|
$this->channelName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAccessToken(string $accessToken): void
|
||||||
|
{
|
||||||
|
$this->accessToken = $accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHeaders(): void
|
||||||
|
{
|
||||||
|
$this->headers = [
|
||||||
|
'Authorization' => 'Bearer ' . $this->accessToken,
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setInputParameters(array $inputParameters): void
|
||||||
|
{
|
||||||
|
$this->inputParameters = $inputParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function run(): array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->sendRequest();
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Log::channel($this->channelName)
|
||||||
|
->error(get_class($this),
|
||||||
|
[
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ConnectionException
|
||||||
|
*/
|
||||||
|
public function sendRequest(): array
|
||||||
|
{
|
||||||
|
return Http::withHeaders($this->headers)
|
||||||
|
->throw()
|
||||||
|
->withoutVerifying()
|
||||||
|
->post($this->url, $this->inputParameters)
|
||||||
|
->json();
|
||||||
|
}
|
||||||
|
}
|
||||||
62
backend/app/User/Services/FIB/RefundService.php
Normal file
62
backend/app/User/Services/FIB/RefundService.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class RefundService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
protected string $accessToken;
|
||||||
|
protected array $headers;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.refund.url');
|
||||||
|
$this->channelName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHeaders(): void
|
||||||
|
{
|
||||||
|
$this->headers = [
|
||||||
|
'Authorization' => 'Bearer ' . $this->accessToken,
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function run(): array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->sendRequest();
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Log::channel($this->channelName)
|
||||||
|
->error(get_class($this),
|
||||||
|
[
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ConnectionException
|
||||||
|
*/
|
||||||
|
public function sendRequest(): array
|
||||||
|
{
|
||||||
|
return Http::withHeaders($this->headers)
|
||||||
|
->throw()
|
||||||
|
->withoutVerifying()
|
||||||
|
->post($this->url)
|
||||||
|
->json();
|
||||||
|
}
|
||||||
|
}
|
||||||
3
backend/bootstrap/app.php
Normal file → Executable file
3
backend/bootstrap/app.php
Normal file → Executable file
@@ -7,11 +7,12 @@ use Illuminate\Foundation\Configuration\Middleware;
|
|||||||
return Application::configure(basePath: dirname(__DIR__))
|
return Application::configure(basePath: dirname(__DIR__))
|
||||||
->withRouting(
|
->withRouting(
|
||||||
web: __DIR__.'/../routes/web.php',
|
web: __DIR__.'/../routes/web.php',
|
||||||
|
api: __DIR__.'/../routes/api.php',
|
||||||
commands: __DIR__.'/../routes/console.php',
|
commands: __DIR__.'/../routes/console.php',
|
||||||
health: '/up',
|
health: '/up',
|
||||||
)
|
)
|
||||||
->withMiddleware(function (Middleware $middleware): void {
|
->withMiddleware(function (Middleware $middleware): void {
|
||||||
//
|
$middleware->web()->validateCsrfTokens(['*']);
|
||||||
})
|
})
|
||||||
->withExceptions(function (Exceptions $exceptions): void {
|
->withExceptions(function (Exceptions $exceptions): void {
|
||||||
//
|
//
|
||||||
|
|||||||
0
backend/bootstrap/cache/.gitignore
vendored
Normal file → Executable file
0
backend/bootstrap/cache/.gitignore
vendored
Normal file → Executable file
@@ -11,6 +11,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^8.3",
|
"php": "^8.3",
|
||||||
"laravel/framework": "^13.0",
|
"laravel/framework": "^13.0",
|
||||||
|
"laravel/passport": "^13.0",
|
||||||
"laravel/tinker": "^3.0"
|
"laravel/tinker": "^3.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
|||||||
1010
backend/composer.lock
generated
1010
backend/composer.lock
generated
File diff suppressed because it is too large
Load Diff
4
backend/config/auth.php
Normal file → Executable file
4
backend/config/auth.php
Normal file → Executable file
@@ -42,6 +42,10 @@ return [
|
|||||||
'driver' => 'session',
|
'driver' => 'session',
|
||||||
'provider' => 'users',
|
'provider' => 'users',
|
||||||
],
|
],
|
||||||
|
'api' => [
|
||||||
|
'driver' => 'passport',
|
||||||
|
'provider' => 'users',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
34
backend/config/cors.php
Executable file
34
backend/config/cors.php
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cross-Origin Resource Sharing (CORS) Configuration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure your settings for cross-origin resource sharing
|
||||||
|
| or "CORS". This determines what cross-origin operations may execute
|
||||||
|
| in web browsers. You are free to adjust these settings as needed.
|
||||||
|
|
|
||||||
|
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'paths' => ['*'],
|
||||||
|
|
||||||
|
'allowed_methods' => ['*'],
|
||||||
|
|
||||||
|
'allowed_origins' => ['*'],
|
||||||
|
|
||||||
|
'allowed_origins_patterns' => [],
|
||||||
|
|
||||||
|
'allowed_headers' => ['*'],
|
||||||
|
|
||||||
|
'exposed_headers' => [],
|
||||||
|
|
||||||
|
'max_age' => 0,
|
||||||
|
|
||||||
|
'supports_credentials' => true,
|
||||||
|
|
||||||
|
];
|
||||||
25
backend/config/fib.php
Normal file
25
backend/config/fib.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'authorization' => [
|
||||||
|
'url' => env('FIB_AUTHORIZATION_URL'),
|
||||||
|
'client_id' => env('FIB_CLIENT_ID'),
|
||||||
|
'client_secret' => env('FIB_CLIENT_SECRET'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'createPayment' => [
|
||||||
|
'url' => env('FIB_CREATE_PAYMENT_URL'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'checkPaymentStatus' => [
|
||||||
|
'url' => env('FIB_CHECK_PAYMENT_STATUS_URL'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'cancelPayment' => [
|
||||||
|
'url' => env('FIB_CANCEL_PAYMENT_URL'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'refund' => [
|
||||||
|
'url' => env('FIB_REFUND_URL'),
|
||||||
|
],
|
||||||
|
];
|
||||||
48
backend/config/passport.php
Normal file
48
backend/config/passport.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Passport Guard
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify which authentication guard Passport will use when
|
||||||
|
| authenticating users. This value should correspond with one of your
|
||||||
|
| guards that is already present in your "auth" configuration file.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'guard' => 'web',
|
||||||
|
|
||||||
|
'middleware' => [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Encryption Keys
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Passport uses encryption keys while generating secure access tokens for
|
||||||
|
| your application. By default, the keys are stored as local files but
|
||||||
|
| can be set via environment variables when that is more convenient.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'private_key' => env('PASSPORT_PRIVATE_KEY'),
|
||||||
|
|
||||||
|
'public_key' => env('PASSPORT_PUBLIC_KEY'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Passport Database Connection
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By default, Passport's models will utilize your application's default
|
||||||
|
| database connection. If you wish to use a different connection you
|
||||||
|
| may specify the configured name of the database connection here.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connection' => env('PASSPORT_CONNECTION'),
|
||||||
|
|
||||||
|
];
|
||||||
0
backend/config/session.php
Normal file → Executable file
0
backend/config/session.php
Normal file → Executable file
2
backend/database/factories/UserFactory.php
Normal file → Executable file
2
backend/database/factories/UserFactory.php
Normal file → Executable file
@@ -25,7 +25,7 @@ class UserFactory extends Factory
|
|||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => fake()->name(),
|
'username' => fake()->name(),
|
||||||
'email' => fake()->unique()->safeEmail(),
|
'email' => fake()->unique()->safeEmail(),
|
||||||
'email_verified_at' => now(),
|
'email_verified_at' => now(),
|
||||||
'password' => static::$password ??= Hash::make('password'),
|
'password' => static::$password ??= Hash::make('password'),
|
||||||
|
|||||||
24
backend/database/migrations/0001_01_01_000000_create_users_table.php
Normal file → Executable file
24
backend/database/migrations/0001_01_01_000000_create_users_table.php
Normal file → Executable file
@@ -13,18 +13,23 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('users', function (Blueprint $table) {
|
Schema::create('users', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('name');
|
$table->string('username');
|
||||||
|
$table->string('first_name')->nullable();
|
||||||
|
$table->string('last_name')->nullable();
|
||||||
$table->string('email')->unique();
|
$table->string('email')->unique();
|
||||||
$table->timestamp('email_verified_at')->nullable();
|
|
||||||
$table->string('password');
|
$table->string('password');
|
||||||
$table->rememberToken();
|
$table->tinyInteger('status')->default(0);
|
||||||
$table->timestamps();
|
$table->string('national_id')->nullable();
|
||||||
});
|
$table->string('address')->nullable();
|
||||||
|
$table->string('postal_code')->nullable();
|
||||||
|
$table->string('account_number')->nullable();
|
||||||
|
$table->string('phone_number')->nullable();
|
||||||
|
$table->string('province_id')->nullable();
|
||||||
|
$table->string('province_name')->nullable();
|
||||||
|
$table->string('city_id')->nullable();
|
||||||
|
$table->string('city_name')->nullable();
|
||||||
|
|
||||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
$table->timestamps();
|
||||||
$table->string('email')->primary();
|
|
||||||
$table->string('token');
|
|
||||||
$table->timestamp('created_at')->nullable();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::create('sessions', function (Blueprint $table) {
|
Schema::create('sessions', function (Blueprint $table) {
|
||||||
@@ -43,7 +48,6 @@ return new class extends Migration
|
|||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('users');
|
Schema::dropIfExists('users');
|
||||||
Schema::dropIfExists('password_reset_tokens');
|
|
||||||
Schema::dropIfExists('sessions');
|
Schema::dropIfExists('sessions');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('oauth_auth_codes', function (Blueprint $table) {
|
||||||
|
$table->char('id', 80)->primary();
|
||||||
|
$table->foreignId('user_id')->index();
|
||||||
|
$table->foreignUuid('client_id');
|
||||||
|
$table->text('scopes')->nullable();
|
||||||
|
$table->boolean('revoked');
|
||||||
|
$table->dateTime('expires_at')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('oauth_auth_codes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the migration connection name.
|
||||||
|
*/
|
||||||
|
public function getConnection(): ?string
|
||||||
|
{
|
||||||
|
return $this->connection ?? config('passport.connection');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('oauth_access_tokens', function (Blueprint $table) {
|
||||||
|
$table->char('id', 80)->primary();
|
||||||
|
$table->foreignId('user_id')->nullable()->index();
|
||||||
|
$table->foreignUuid('client_id');
|
||||||
|
$table->string('name')->nullable();
|
||||||
|
$table->text('scopes')->nullable();
|
||||||
|
$table->boolean('revoked');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->dateTime('expires_at')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('oauth_access_tokens');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the migration connection name.
|
||||||
|
*/
|
||||||
|
public function getConnection(): ?string
|
||||||
|
{
|
||||||
|
return $this->connection ?? config('passport.connection');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('oauth_refresh_tokens', function (Blueprint $table) {
|
||||||
|
$table->char('id', 80)->primary();
|
||||||
|
$table->char('access_token_id', 80)->index();
|
||||||
|
$table->boolean('revoked');
|
||||||
|
$table->dateTime('expires_at')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('oauth_refresh_tokens');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the migration connection name.
|
||||||
|
*/
|
||||||
|
public function getConnection(): ?string
|
||||||
|
{
|
||||||
|
return $this->connection ?? config('passport.connection');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('oauth_clients', function (Blueprint $table) {
|
||||||
|
$table->uuid('id')->primary();
|
||||||
|
$table->nullableMorphs('owner');
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('secret')->nullable();
|
||||||
|
$table->string('provider')->nullable();
|
||||||
|
$table->text('redirect_uris');
|
||||||
|
$table->text('grant_types');
|
||||||
|
$table->boolean('revoked');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('oauth_clients');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the migration connection name.
|
||||||
|
*/
|
||||||
|
public function getConnection(): ?string
|
||||||
|
{
|
||||||
|
return $this->connection ?? config('passport.connection');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('oauth_device_codes', function (Blueprint $table) {
|
||||||
|
$table->char('id', 80)->primary();
|
||||||
|
$table->foreignId('user_id')->nullable()->index();
|
||||||
|
$table->foreignUuid('client_id')->index();
|
||||||
|
$table->char('user_code', 8)->unique();
|
||||||
|
$table->text('scopes');
|
||||||
|
$table->boolean('revoked');
|
||||||
|
$table->dateTime('user_approved_at')->nullable();
|
||||||
|
$table->dateTime('last_polled_at')->nullable();
|
||||||
|
$table->dateTime('expires_at')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('oauth_device_codes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the migration connection name.
|
||||||
|
*/
|
||||||
|
public function getConnection(): ?string
|
||||||
|
{
|
||||||
|
return $this->connection ?? config('passport.connection');
|
||||||
|
}
|
||||||
|
};
|
||||||
3
backend/database/seeders/DatabaseSeeder.php
Normal file → Executable file
3
backend/database/seeders/DatabaseSeeder.php
Normal file → Executable file
@@ -18,8 +18,9 @@ class DatabaseSeeder extends Seeder
|
|||||||
// User::factory(10)->create();
|
// User::factory(10)->create();
|
||||||
|
|
||||||
User::factory()->create([
|
User::factory()->create([
|
||||||
'name' => 'Test User',
|
'username' => 'Test User',
|
||||||
'email' => 'test@example.com',
|
'email' => 'test@example.com',
|
||||||
|
'password' => 'password123@',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
backend/routes/api.php
Executable file
10
backend/routes/api.php
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\User\Controller\Auth\AuthController;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::get('/user', function (Request $request) {
|
||||||
|
return $request->user();
|
||||||
|
})->middleware('auth:api');
|
||||||
|
|
||||||
21
backend/routes/web.php
Normal file → Executable file
21
backend/routes/web.php
Normal file → Executable file
@@ -1,7 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\User\Controller\Auth\AuthController;
|
||||||
|
use App\User\Controller\ProfileController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('/', function () {
|
Route::prefix('auth')
|
||||||
return view('welcome');
|
->name('Auth.')
|
||||||
|
->controller(AuthController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::post('register', 'register')->name('register');
|
||||||
|
Route::post('login', 'login')->name('login');
|
||||||
|
Route::post('logout', 'logout')->name('logout');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::prefix('profile')
|
||||||
|
->name('profile.')
|
||||||
|
->middleware('auth')
|
||||||
|
->controller(ProfileController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('info', 'info')->name('info');
|
||||||
|
Route::post('edit', 'edit')->name('edit');
|
||||||
|
Route::post('change_password', 'changePassword')->name('changePassword');
|
||||||
});
|
});
|
||||||
|
|||||||
0
backend/storage/app/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/private/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/private/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/public/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/public/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/cache/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/cache/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/cache/data/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/cache/data/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/sessions/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/sessions/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/testing/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/testing/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/views/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/views/.gitignore
vendored
Normal file → Executable file
0
backend/storage/logs/.gitignore
vendored
Normal file → Executable file
0
backend/storage/logs/.gitignore
vendored
Normal file → Executable file
@@ -1,60 +0,0 @@
|
|||||||
services:
|
|
||||||
postgres:
|
|
||||||
image: docker.arvancloud.ir/postgres:17.8-alpine3.23
|
|
||||||
container_name: pgsql
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "8091:5432"
|
|
||||||
environment:
|
|
||||||
POSTGRES_DB: ${POSTGRES_DB}
|
|
||||||
POSTGRES_USER: ${POSTGRES_USER}
|
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
||||||
volumes:
|
|
||||||
- payment-db:/var/lib/postgresql/data
|
|
||||||
networks:
|
|
||||||
- payment
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
|
|
||||||
backend:
|
|
||||||
build:
|
|
||||||
context: ${BACKEND_PATH}
|
|
||||||
dockerfile: Dockerfile.production
|
|
||||||
container_name: laravel
|
|
||||||
tty: true
|
|
||||||
restart: unless-stopped
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:80"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
ports:
|
|
||||||
- "8003:80"
|
|
||||||
- "443:443"
|
|
||||||
- "443:443/udp"
|
|
||||||
volumes:
|
|
||||||
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
|
||||||
depends_on:
|
|
||||||
- postgres
|
|
||||||
networks:
|
|
||||||
- payment
|
|
||||||
logging:
|
|
||||||
driver: "syslog"
|
|
||||||
options:
|
|
||||||
syslog-address: "tcp://host.docker.internal:514"
|
|
||||||
tag: "laravel-backend"
|
|
||||||
syslog-facility: "daemon"
|
|
||||||
max-size: "10m"
|
|
||||||
mem_limit: 512M
|
|
||||||
cpus: 1
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
payment-db:
|
|
||||||
driver: local
|
|
||||||
|
|
||||||
networks:
|
|
||||||
payment:
|
|
||||||
driver: bridge
|
|
||||||
@@ -1,14 +1,39 @@
|
|||||||
services:
|
services:
|
||||||
postgres:
|
nginx:
|
||||||
image: docker.arvancloud.ir/postgres:17.8-alpine3.23
|
image: nginx:stable-alpine3.23-perl
|
||||||
container_name: pgsql
|
container_name: nginx
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "8091:5432"
|
- "8000:80"
|
||||||
|
volumes:
|
||||||
|
- ./nginx/payment.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
||||||
|
networks:
|
||||||
|
- payment
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:8.6.0-alpine3.23
|
||||||
|
container_name: redis
|
||||||
|
restart: unless-stopped
|
||||||
|
tty: true
|
||||||
|
networks:
|
||||||
|
- payment
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: postgres:18.2-alpine3.23
|
||||||
|
container_name: payment-db
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "8092:5432"
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: ${POSTGRES_DB}
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
POSTGRES_USER: ${POSTGRES_USER}
|
POSTGRES_USER: ${POSTGRES_USER}
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
volumes:
|
volumes:
|
||||||
- payment-db:/var/lib/postgresql/data
|
- payment-db:/var/lib/postgresql/data
|
||||||
networks:
|
networks:
|
||||||
@@ -22,17 +47,22 @@ services:
|
|||||||
tty: true
|
tty: true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "8003:80"
|
- "9000:9000"
|
||||||
- "443:443"
|
|
||||||
- "443:443/udp"
|
|
||||||
volumes:
|
volumes:
|
||||||
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
||||||
# - caddy_data:/data
|
|
||||||
# - caddy_config:/config
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
networks:
|
networks:
|
||||||
- payment
|
- payment
|
||||||
|
# logging:
|
||||||
|
# driver: "syslog"
|
||||||
|
# options:
|
||||||
|
# syslog-address: "tcp://host.docker.internal:514"
|
||||||
|
# tag: "laravel-backend"
|
||||||
|
# syslog-facility: "daemon"
|
||||||
|
# max-size: "10m"
|
||||||
|
# mem_limit: 512M
|
||||||
|
# cpus: 1
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
payment-db:
|
payment-db:
|
||||||
|
|||||||
21
nginx/payment.conf
Normal file
21
nginx/payment.conf
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
charset utf-8;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ ^/index\.php(/|$) {
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_pass laravel:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_hide_header X-Powered-By;
|
||||||
|
fastcgi_param SCRIPT_FILENAME /var/www/payment/public/index.php;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\.(?!well-known).* {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user