Merge pull request #307 from cuneytsenturk/1.2-dev

App store token verification
This commit is contained in:
Cüneyt Şentürk 2018-04-25 16:58:20 +03:00 committed by GitHub
commit b58c29a648
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 1 deletions

View File

@ -3,9 +3,26 @@
namespace App\Http\Requests\Module; namespace App\Http\Requests\Module;
use App\Http\Requests\Request; use App\Http\Requests\Request;
use Illuminate\Validation\Factory as ValidationFactory;
use App\Traits\Modules;
class Module extends Request 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. * Determine if the user is authorized to make this request.
* *
@ -24,7 +41,7 @@ class Module extends Request
public function rules() public function rules()
{ {
return [ return [
'api_token' => 'required|string', 'api_token' => 'required|string|check',
]; ];
} }
} }

View File

@ -12,6 +12,25 @@ use ZipArchive;
trait Modules 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() public function getModules()
{ {
$response = $this->getRemote('apps/items'); $response = $this->getRemote('apps/items');

View File

@ -4,6 +4,7 @@ return [
'title' => 'API Token', 'title' => 'API Token',
'api_token' => 'Token', 'api_token' => 'Token',
'invalid_token' => 'Sorry, it invalid token validation!',
'top_paid' => 'Top Paid', 'top_paid' => 'Top Paid',
'new' => 'New', 'new' => 'New',
'top_free' => 'Top Free', 'top_free' => 'Top Free',