Initial import
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?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->email) && !empty($postDecode->password)) {
|
||||
$email = $postDecode->email;
|
||||
$password = $postDecode->password;
|
||||
$user = UserPublic::find()->where(['email' => $email])->one();
|
||||
|
||||
|
||||
if(!empty($_GET['partner'])) {
|
||||
if(sizeof($user->qrValidators) == 0) {
|
||||
echo json_encode(['error' => 'wrong_user']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
//echo json_encode(['email' => $user->email, 'password' => password_verify($password, $user->password_hash), 'hash' => $user->password_hash]);
|
||||
//exit;
|
||||
if ($user && password_verify($password, $user->password_hash)) {
|
||||
$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