Untitled
unknown
plain_text
5 months ago
2.8 kB
3
Indexable
public function actionLogin() { // if (!Yii::$app->user->isGuest) { // return $this->goHome(); // } // $model = new LoginForm(); // if ($model->load(Yii::$app->request->post()) && $model->login()) { // return $this->goBack(); // } else { // $this->layout = "main-login"; // $model->password = ''; // return $this->render('login', [ // 'model' => $model, // ]); // } $connection = \Yii::$app->db; \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $out = ['success' => 0, 'data' => [], 'message' => ""]; if ($post = Yii::$app->request->post()) { if (array_key_exists("phone", $post)) { if ($post['phone'] == '' and $post['phone'] == null) { $out['message'] = "Nomor Whatsapp Kosong!"; return $out; die; } } else { $out['message'] = "Failed, parameter blank!"; return $out; die; } $post['phone'] = (int)$post['phone']; $post['phone'] = "62" . $post['phone']; $model = User::find() ->where(['phone' => $post['phone']]) ->andWhere(['userTypeId' => 1]) //seller dan toko // ->andWhere(['storeId' => null]) ->orderBy([ 'id' => SORT_ASC, ])->one(); if ($model != null) { $account = Account::find()->where(['id' => $model['accountId']])->one(); $out['success'] = 1; // $out['data'] = []; // $out['data']['user'] = $model; // $out['data']['type_user'] = $model->storeId==null?"owner":"toko"; // $out['data']['account'] = $account; $otp_baru = rand(1000, 9999); $connection->createCommand() ->update('user', [ 'otp' => $otp_baru, 'modifiedBy' => $model['id'], 'modifiedDate' => date('Y-m-d H:i:s') ], 'id = ' . $model->id) ->execute(); // $out['data']['otp'] = $otp_baru; $phone = $model['phone']; $send_otp = $this->actionSendWa($phone, $otp_baru, 'waOrderAja'); // $out['data']['send_otp'] = json_decode($send_otp); } else { $out['message'] = "Nomor Whatsapp Tidak Terdaftar!"; } } else { $out['message'] = "Failed, parameter blank!"; return $out; die; } return $out; }
Editor is loading...
Leave a Comment