Skip to content

Commit

Permalink
fix ver
Browse files Browse the repository at this point in the history
  • Loading branch information
xxl4 committed Jun 25, 2024
1 parent 27b2157 commit 928747d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Config/Apis.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
return [
'name' => 'Apis',
'version' => '1.0.0',
'versionNum' => '100',
'version' => '1.0.4',
'versionNum' => '104',
];
2 changes: 1 addition & 1 deletion src/Docs/V1/Admin/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* @OA\Info(
* version="1.0.2",
* version="1.0.4",
* title="NexaMerchant Admin Rest API Documentation",
* description="NexaMerchant Admin Rest API Documentation",
*
Expand Down
2 changes: 1 addition & 1 deletion src/Docs/V1/Shop/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* @OA\Info(
* version="1.0.2",
* version="1.0.4",
* title="NexaMerchant Store Front Rest API Documentation",
* description="NexaMerchant Store Front Rest API Documentation",
*
Expand Down
36 changes: 36 additions & 0 deletions src/Http/Controllers/Api/V1/Shop/Customer/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Password;
use Webkul\Core\Rules\AlphaNumericSpace;
use Illuminate\Validation\ValidationException;
Expand Down Expand Up @@ -281,6 +282,13 @@ public function getCode(Request $request)
}

$code = mt_rand(100000, 999999);
Cache::put(md5($request->email), $code, 300); // 5 * 60 minutes

//send email to user



return response(['message' => trans('Apis::app.shop.customer.code.sent')]);

}

Expand All @@ -296,5 +304,33 @@ public function LoginWithCode(Request $request)
if (! $customer) {
return response(['message' => 'Customer not found'], 404);
}

$code = Cache::get(md5($request->email));
if($code!= $request->code){
return response(['message' => 'Invalid code'], 404);
}
if (! EnsureFrontendRequestsAreStateful::fromFrontend($request)) {
$request->validate([
'device_name' => 'required',
]);

$customer = $this->customerRepository->where('email', $request->email)->first();

/**
* Preventing multiple token creation.
*/
$customer->tokens()->delete();

/**
* Event passed to prepare cart after login.
*/
Event::dispatch('customer.after.login', $request->get('email'));

return response([
'data' => new CustomerResource($customer),
'message' => trans('Apis::app.shop.customer.accounts.logged-in-success'),
'token' => $customer->createToken($request->device_name, ['role:customer'])->plainTextToken,
]);
}
}
}

0 comments on commit 928747d

Please sign in to comment.