Initial import
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?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->device_id) && !empty($postDecode->uid)) {
|
||||
$device_id = $postDecode->device_id;
|
||||
$uid = $postDecode->uid;
|
||||
$user = UserPublic::find()->where(['device_id' => $device_id])->one();
|
||||
if ($user) {
|
||||
$decode = JWT::decode($user->device_id, JWT::SECRET_KEY);
|
||||
if($decode->uid == $uid) {
|
||||
$user->is_mobile_user = 1;
|
||||
$user->save();
|
||||
echo json_encode(['userToken' => JWT::encode(['id' => $user->id], JWT::SECRET_KEY), 'profile'=> $user->profileData()]);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo json_encode(['error' => 'wrong_user']);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo json_encode(['error' => 'wrong_user']);
|
||||
exit;
|
||||
}
|
||||
Reference in New Issue
Block a user