Initial import
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
header('Content-type: application/json');
|
||||
|
||||
use app\models\UserPublic;
|
||||
use app\services\JWT;
|
||||
|
||||
$post = \Yii::$app->request->getRawBody();
|
||||
|
||||
|
||||
$postDecode = json_decode($post);
|
||||
|
||||
if(!empty($postDecode->uid)) {
|
||||
|
||||
function loop($postDecode)
|
||||
{
|
||||
|
||||
if (!$postDecode->uid) return;
|
||||
$server_id = md5(time() . uniqid());
|
||||
$uid = $postDecode->uid;
|
||||
$token = JWT::encode(['server_id' => $server_id, 'uid' => $uid], JWT::SECRET_KEY);
|
||||
$user = UserPublic::find()->where(['device_id' => $token])->exists();
|
||||
if (!$user) {
|
||||
echo json_encode(['device_id' => $token]);
|
||||
exit;
|
||||
} else {
|
||||
loop($postDecode);
|
||||
}
|
||||
}
|
||||
|
||||
loop($postDecode);
|
||||
}
|
||||
exit;
|
||||
Reference in New Issue
Block a user