account update authorization fixed

This commit is contained in:
ilmedova 2022-07-19 10:07:31 +05:00
parent 35379b7e34
commit 424fd97366
5 changed files with 131 additions and 47 deletions

View File

@ -1,10 +1,4 @@
<?php
/**
* Created by PhpStorm.
* User: merdan
* Date: 7/14/2022
* Time: 14:06
*/
namespace App\Http\Controllers;
@ -42,24 +36,65 @@ public function get(){
}
/**
* @OA\POST(
* path="/api/account",
* summary=" - Update account",
* tags = {"Account"},
* security={
* {"bearerAuth": {}}
* },
* @OA\Response(
* response="200",
* description="OK"
* ),
* @OA\Response(
* response="401",
* description="Unauthorized"
* )
* )
*/
* @OA\POST(
* path="/api/update-account",
* summary=" - Update account",
* tags = {"Account"},
* security={
* {"bearerAuth": {}}
* },
* @OA\RequestBody(
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(
* property="contacts",
* type="string",
* ),
* @OA\Property(
* property="bank",
* type="string",
* ),
* @OA\Property(
* property="vat",
* type="string",
* ),
* @OA\Property(
* property="country_id",
* type="integer",
* ),
* @OA\Property(
* property="legalization_number",
* type="string",
* ),
* @OA\Property(
* property="type",
* type="string",
* ),
* example={"contacts":"{'address':'Ashgabat', 'phone': '+99362553499', 'email': 'ilmedovamahri@gmail.com', 'fax': '414141'}", "bank":"{'account_number':'12345','account_date':'02.02.2022','currency':'USD', 'iban':'747474', 'bank_name':'Vnezhekonom', 'country':'France'}" ,"vat": "123123", "country_id": 1, "legalization_number": "123456","type":"business"}
* )
* )
* ),
* @OA\Parameter(
* description="Localization",
* in="header",
* name="X-Localization",
* required=false,
* @OA\Schema(type="string"),
* @OA\Examples(example="ru", value="ru", summary="Russian localization"),
* @OA\Examples(example="en", value="en", summary="English localization"),
* @OA\Examples(example="tm", value="tm", summary="Turkmen localization"),
* ),
* @OA\Response(
* response="200",
* description="OK"
* ),
* @OA\Response(
* response="401",
* description="Unauthorized"
* )
* )
*/
public function update(AccountRequest $request){
$client = $request->user();

View File

@ -13,7 +13,7 @@ class AccountRequest extends FormRequest
*/
public function authorize()
{
return false;
return true;
}
/**

View File

@ -2,8 +2,7 @@
use App\Http\Controllers\AuthController;
use App\Http\Controllers\ResourceController;
use App\Http\Controllers\TestController;
use Illuminate\Http\Request;
use App\Http\Controllers\AccountController;
use Illuminate\Support\Facades\Route;
/*
@ -11,26 +10,18 @@
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
// Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
// });
Route::middleware(['localization'])->group(function (){
Route::post('/register', [AuthController::class, 'register']);
Route::post('/login', [AuthController::class, 'login'])->middleware("throttle:3,30");;
Route::post('/reset-password', [AuthController::class, 'updatePassword']);
Route::post('/forgot-password', [AuthController::class, 'sendPasswordResetLinkEmail']);
Route::post('/verify-email', [AuthController::class, 'verifyEmail']);
Route::get('countries', [ResourceController::class, 'countries']);
Route::get('/countries', [ResourceController::class, 'countries']);
});
Route::middleware(['auth.client','auth:api', 'localization'])->group(function () {
Route::middleware(['localization', 'auth.client', 'auth:api'])->group(function (){
/*
* Client Api's
*/
@ -40,6 +31,6 @@
/*
* Account
*/
Route::get('account',[\App\Http\Controllers\AccountController::class,'get']);
Route::post('account',[\App\Http\Controllers\AccountController::class,'update']);
Route::get('/account',[AccountController::class,'get']);
Route::post('/update-account',[AccountController::class,'update']);
});

View File

@ -8,14 +8,8 @@
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('/forgot-password/{token}', [AuthController::class, 'forgotPasswordValidate']);
Route::put('reset-password', [AuthController::class, 'updatePassword'])->name('reset-password');

View File

@ -25,13 +25,77 @@
"bearerAuth": []
}
]
},
}
},
"/api/update-account": {
"post": {
"tags": [
"Account"
],
"summary": " - Update account",
"operationId": "2de5743bd87f04fc0cd5f63d0a630959",
"operationId": "6ea7ff278482a27e7d53c8ac595c6547",
"parameters": [
{
"name": "X-Localization",
"in": "header",
"description": "Localization",
"required": false,
"schema": {
"type": "string"
},
"examples": {
"ru": {
"summary": "Russian localization",
"value": "ru"
},
"en": {
"summary": "English localization",
"value": "en"
},
"tm": {
"summary": "Turkmen localization",
"value": "tm"
}
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"contacts": {
"type": "string"
},
"bank": {
"type": "string"
},
"vat": {
"type": "string"
},
"country_id": {
"type": "integer"
},
"legalization_number": {
"type": "string"
},
"type": {
"type": "string"
}
},
"type": "object",
"example": {
"contacts": "{'address':'Ashgabat', 'phone': '+99362553499', 'email': 'ilmedovamahri@gmail.com', 'fax': '414141'}",
"bank": "{'account_number':'12345','account_date':'02.02.2022','currency':'USD', 'iban':'747474', 'bank_name':'Vnezhekonom', 'country':'France'}",
"vat": "123123",
"country_id": 1,
"legalization_number": "123456",
"type": "business"
}
}
}
}
},
"responses": {
"200": {
"description": "OK"