App store token verify
This commit is contained in:
parent
f9e7da3017
commit
244b5aabbe
@ -3,9 +3,26 @@
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use Illuminate\Validation\Factory as ValidationFactory;
|
||||
use App\Traits\Modules;
|
||||
|
||||
class Module extends Request
|
||||
{
|
||||
use Modules;
|
||||
|
||||
public function __construct(ValidationFactory $validationFactory)
|
||||
{
|
||||
|
||||
$validationFactory->extend(
|
||||
'check',
|
||||
function ($attribute, $value, $parameters) {
|
||||
return $this->checkToken($value);
|
||||
},
|
||||
trans('modules.invalid_token')
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
@ -24,7 +41,7 @@ class Module extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'api_token' => 'required|string',
|
||||
'api_token' => 'required|string|check',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,25 @@ use ZipArchive;
|
||||
trait Modules
|
||||
{
|
||||
|
||||
public function checkToken($token)
|
||||
{
|
||||
$data = [
|
||||
'form_params' => [
|
||||
'token' => $token,
|
||||
]
|
||||
];
|
||||
|
||||
$response = $this->getRemote('token/check', 'POST', $data);
|
||||
|
||||
if ($response->getStatusCode() == 200) {
|
||||
$result = json_decode($response->getBody());
|
||||
|
||||
return ($result->success) ? true : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getModules()
|
||||
{
|
||||
$response = $this->getRemote('apps/items');
|
||||
|
@ -4,6 +4,7 @@ return [
|
||||
|
||||
'title' => 'API Token',
|
||||
'api_token' => 'Token',
|
||||
'invalid_token' => 'Sorry, it invalid token validation!',
|
||||
'top_paid' => 'Top Paid',
|
||||
'new' => 'New',
|
||||
'top_free' => 'Top Free',
|
||||
|
Loading…
x
Reference in New Issue
Block a user